|
-
Dec 10th, 2003, 03:18 PM
#1
Has a session variable been created?
How do you test if a session variable has been created? I assume it is Is this a correct way of doing it?
-
Dec 10th, 2003, 07:05 PM
#2
Lively Member
I'm not sure of the "right way" for that.
But I use this:
VB Code:
<%
If Len(Session("alert")) > 0 Then
Response.Write "alert session does exist"
End If
%>
And, the right way to check if it's null goes with "IsNull" function:
VB Code:
If Not IsNull(anyVariable) Then
Response.Write "anyVariable is not null, but it could be empty"
End If
Anyway, here is the result I got after a few tests:
Code:
variable / session IsNull IsEmpty Len = 0
Not Declared / Created false true true
= "" false false true
= Null true false true
= Empty false true true
= "anything" false false false
That means, if you check for Null, Empty or Len(var) = 0 of a variable right on the first line of the file (before anything else, including declarations, etc), you'll get the results on the first line. And it works for session as well, since they're treated as variables.
--
Cauê Cavalheiro Machado Rego
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|