1

Can't detect whether Session variable exists

my code is:

if session("something") then end if

any way to validate this?

greetings

patovega
  • 343
  • 2
  • 5
  • 16

2 Answers2

2

Assuming this is VB.NET:

If Not (session("something") Is Nothing) Then
    ' use session("something")
End If
D Stanley
  • 149,601
  • 11
  • 178
  • 240
1

VB.NET:

If session("whatever") is nothing then
    do something
Else
    do something else
End if

Have this code in the Page_Load()

if(Session["SessionName"] == null)
{
    //Session Does not Exists
}
else
{
    //Session Exists
}

or Refer:

What is the best way to determine a session variable is null or empty in C#?

Community
  • 1
  • 1
Jatin
  • 3,065
  • 6
  • 28
  • 42