Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Maintaining the Session Id through out the Session

0.00/5 (No votes)
8 Apr 2010 1  
 Hi,  Many of us come across situation like, just need a unique session id through out the session irrespective of whether the data is stored in

This articles was originally at wiki.asp.net but has now been given a new home on CodeProject. Editing rights for this article has been set at Bronze or above, so please go in and edit and update this article to keep it fresh and relevant.

 Hi,

  Many of us come across situation like, just need a unique session id through out the session irrespective of whether the data is stored in the session or not. If you just write like,

               String strSessionId = Session.SessionId;

It will fectch the Unique session id, but, if page refreshes or any Postback occurs on the page, again u will end in another unique session id. 

There are two ways to avoid this.

1. Modify your web.config file in the <system.web> section

                 <system.web> <sessionState cookieless="true" > </system.web>

2.Add Global.asax file, to your application, and handle Session_Start() event handler, so that the session id generated once, can be lasted for the entire session.

Hope this helps you

Thanks & Regards

Roopesh Reddy C 

 

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here