Name
SessionID
Synopsis
String = Session. SessionID
Returns a String containing the unique identifier for the current session.
Parameters
-
String
A String variable that will receive the session ID property value.
Example
See the example for the IsReadOnly property.
Notes
The SessionID property value is generated the first time that a page
for which session state has not been disabled is requested. As noted
earlier, the actual session is not created unless either an event
handler is provided in global.asax
for the
Session.Start event or a value is stored in the Session collection.
The SessionID is stored on the client in a nonpersistent cookie, or
if cookieless sessions are enabled, is passed as part of each URL
request.
Note that if the client’s browser is closed, the
client will be unable to access their session (since the
nonpersistent cookie will be destroyed when the browser is closed),
but the session will continue to exist on the server until the
configured timeout period has elapsed. If you want to explicitly
expire a session, you can check the IsClientConnected property of the
HttpResponse
class, which returns a Boolean
indicating whether the client has disconnected. If it returns
False
, you can then call Session.Abandon to expire
the session.
While the SessionID value, which is a 120-bit ASCII string in ASP.NET, is unique to a given IIS application instance, it is not guaranteed to be universally unique and therefore should not be used for database identity values or for other ...
Get ASP.NET in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.