What is main different between session and session ID? [Resolved]

Posted by Allemahesh under ASP.NET on 8/19/2013 | Points: 10 | Views : 1988 | Status : [Member] [MVP] | Replies : 2
Can any one tell me what is main different between session and session ID?
Can I say session and session ID is the same?


Posted by: Satyapriyanayak on: 8/19/2013 [Member] [MVP] Silver | Points: 50



If this post helps you mark it as answer

Allemahesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 8/20/2013 [Member] [MVP] Platinum | Points: 25

Hi Mahesh,
Session is an object that provides a facility to store information on server memory. The information stored in the server is called as sessionId. Based on that SessionID web browser can able to remember the previous calls of the page...

Refer this link: http://www.codeproject.com/Articles/32545/Exploring-Session-in-ASP-Net#2
Simply I can say that Session is an object and SessionID is the information that is stored by using Session object.....

When using cookie-based session state, ASP.NET does not allocate storage for session data until the Session object is used. As a result, a new session ID is generated for each page request until the session object is accessed. If your application requires a static session ID for the entire session, you can either implement the Session_Start method in the application's Global.asax file and store data in the Session object to fix the session ID, or you can use code in another part of your application to explicitly store data in the Session object.


So basically, unless you access your session object on the backend, a new sessionId will be generated with each request

This code must be added on the file Global.asax. It adds an entry to the Session object so you fix the session until it expires.

protected void Session_Start(Object sender, EventArgs e) 

Session["init"] = 0;

Mark This Response as Answer

Allemahesh, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response