Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to refer to an empty session variable

Status
Not open for further replies.

aonefun

Technical User
May 21, 2007
79
US
I would like to show some code based on if a session variable contains a value. How do I put this into code:

Is this the right way?:

If session("postalcode")<>""
Then

or do I use something like NOT ISNULL or NOT ISEMPTY?
 
that is commonly used..but i'd use the len function.....make sure to trim the variable to get accurate results

Code:
  Session("my_session_name") = "Bob"

  sMySessionValue = Trim(Session("my_session_name"))
 
  If Len(sMySessionValue) > 0 Then
   Response.Write " 1. My session value is: " & sMySessionValue
  End If

  If sMySessionValue <> "" Then
   Response.Write " 2. My session value is: " & sMySessionValue
  End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top