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!

session variables in vbscript

Status
Not open for further replies.

blexman

Programmer
Jul 18, 2001
34
0
0
CA
I am comparing session variables to null. I am getting different results dependending on how I code the if statement below :
<%....

if isempty(session(&quot;x&quot;)) then ... ;this seems to work INcorrectly if x is null

if isempty(response.write(session(&quot;x&quot;))) then ... ;this works correctly if x is null

or what about

if session(&quot;x&quot;)=nothing then ...

or

if session(&quot;x&quot;)=&quot;&quot; ...

%>

Any suggestions on how to check for null strings in session variables.

thanks
 
Try changing this

if isempty(session(&quot;x&quot;)) then

To this

if isNull(Session(&quot;x&quot;)) or Session(&quot;x&quot;) = &quot;&quot; Then

This should do it for you




 
I usually use if session(&quot;x&quot;)=&quot;&quot; because it can only be null if you expressly set it to null - which I never do. If the variable has never been set, it will return an empty string (&quot;&quot;) Get the Best Answers! faq333-2924
Happy 2003! [cheers]
mikewolf@tst-us.com
 
the isNull works....for whatever reason &quot;&quot; does not work.
thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top