Sessions allow variables to be created in a webpage and to be accessed by another webpage within an application. However they only last for a matter of minutes.
To create a session you use the code: Session("Name") = "Value"To access a session you use the code: lblSession.text = Session("Name")
If Session.Item("Name") IsNot Nothing Then
Response.Write(Session("Name"))
Else
Response.Write("Session Name does not exist")
End If
To make sure an session does exist and to avoid errors you can use an if statement.
For example:If Session.Item("Name") IsNot Nothing Then
Response.Write(Session("Name"))
Else
Response.Write("Session Name does not exist")
End If
No comments:
Post a Comment