session is nothing

Discussion in 'ASP General' started by Joel Brabant, Oct 16, 2003.

  1. Joel Brabant

    Joel Brabant Guest

    How can I know if a user session had timed out ?

    I always get an error in my asp page when I try to access
    my session variable if it timed out.

    Thank You.
     
    Joel Brabant, Oct 16, 2003
    #1
    1. Advertising

  2. Joel Brabant

    Ray at Guest

    What error? What code? Any time you hit your asp page, there's a session,
    whether it's the same one that you had five seconds prior, or a new one.

    Ray at work

    "Joel Brabant" <> wrote in message
    news:085701c3940e$57098300$...
    > How can I know if a user session had timed out ?
    >
    > I always get an error in my asp page when I try to access
    > my session variable if it timed out.
    >
    > Thank You.
     
    Ray at, Oct 16, 2003
    #2
    1. Advertising

  3. Joel Brabant

    Joel Brabant Guest

    The error is : object required....

    The session has timed out.
    For sure my session("blabla") is nothing... I know that.

    But howcome it crashes when I use

    If session("blabla") is nothing then
    ...
    end if

    !!!

    Joel Brabant
    Developer
    Tembec Inc.

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Joel Brabant, Oct 16, 2003
    #3
  4. Joel Brabant

    Ray at Guest

    Are you storing OBJECTS in session variables?

    Ray at work

    "Joel Brabant" <> wrote in message
    news:...
    > The error is : object required....
    >
    > The session has timed out.
    > For sure my session("blabla") is nothing... I know that.
    >
    > But howcome it crashes when I use
    >
    > If session("blabla") is nothing then
    > ..
    > end if
    >
    > !!!
    >
    > Joel Brabant
    > Developer
    > Tembec Inc.
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!
     
    Ray at, Oct 16, 2003
    #4
  5. Joel Brabant

    Ray at Guest

    P.S. Is Nothing only works on variables that have been defined as object
    variables. i.e.

    On Error Resume Next
    Dim x
    response.write "x is nothing?<br>"
    Response.Write x is nothing
    response.write "<br>" & err.description
    err.clear
    response.write "<hr>"


    set x = createobject("adodb.connection")
    response.write "x is now an object<br>"
    response.write x is nothing
    response.write err.description & "<br>"
    err.clear
    response.write "<hr>"


    response.write "x has been destroyed<br>"
    set x = nothing
    response.write x is nothing
    response.write err.description


    If this were VB code and you did:
    dim x as object

    It wouldn't generate the error.

    Ray at work




    ''that will gen
    "Joel Brabant" <> wrote in message
    news:...
    > The error is : object required....
    >
    > The session has timed out.
    > For sure my session("blabla") is nothing... I know that.
    >
    > But howcome it crashes when I use
    >
    > If session("blabla") is nothing then
    > ..
    > end if
    >
    > !!!
    >
    > Joel Brabant
    > Developer
    > Tembec Inc.
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!
     
    Ray at, Oct 16, 2003
    #5
  6. Joel Brabant

    Bob Barrows Guest

    Joel Brabant wrote:
    > The error is : object required....
    >
    > The session has timed out.
    > For sure my session("blabla") is nothing... I know that.
    >
    > But howcome it crashes when I use
    >
    > If session("blabla") is nothing then
    > ..

    Because, unless you are storing an object in session("blabla"),
    session("blabla") will not be an object. Only objects can be Nothing.

    I usually do this:

    If len(session("blabla")) = 0 then

    --
    HTH,
    Bob Barrows - Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.
     
    Bob Barrows, Oct 16, 2003
    #6
  7. Joel Brabant

    Joel Brabant Guest

    Session("oAppUser") is in fact an object that was returned by my vb code
    like this:

    Set oAppTDE = Server.CreateObject("AppTDE.TDEManager")
    Set Session("oAppUser")=oAppTDE.Login(cstr(sUsername),cstr(sPassword))
    Set oAppTDE = Nothing

    Don't worry ! I know, we are not suppose to store objects in session
    variables....but that object has just a couple of properties that's it.

    Thank you all for your help.

    Joel Brabant
    Developer
    Tembec Inc.

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Joel Brabant, Oct 16, 2003
    #7
  8. Joel Brabant

    Bob Barrows Guest

    Joel Brabant wrote:
    > Session("oAppUser") is in fact an object that was returned by my vb
    > code like this:
    >
    > Set oAppTDE = Server.CreateObject("AppTDE.TDEManager")
    > Set Session("oAppUser")=oAppTDE.Login(cstr(sUsername),cstr(sPassword))
    > Set oAppTDE = Nothing
    >
    > Don't worry ! I know, we are not suppose to store objects in session
    > variables....but that object has just a couple of properties that's
    > it.
    >

    What the object stores is not the problem. The problem is whether or not the
    object is free-threaded. If it was created in VB, then it is not
    free-threaded, and storing it in Session is not recommended.

    So, you need to find out if the session variable exists, and if it does
    exist, it will contain an object.

    The first step is to use IsObject to determine if it is an object.

    If IsObject(Session("oAppUser") then
    if not Session("oAppUser") is nothing then


    --
    HTH,
    Bob Barrows - Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.
     
    Bob Barrows, Oct 16, 2003
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mark Rodrigues

    Re: Session variables set to nothing??

    Mark Rodrigues, Oct 29, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    387
    Mark Rodrigues
    Oct 29, 2003
  2. Thanks
    Replies:
    2
    Views:
    1,694
    Thanks
    Feb 8, 2004
  3. Lucas Tam

    Session Object = nothing?

    Lucas Tam, Feb 8, 2005, in forum: ASP .Net
    Replies:
    7
    Views:
    3,400
    Lucas Tam
    Feb 10, 2005
  4. Replies:
    0
    Views:
    344
  5. Devin Jeanpierre
    Replies:
    2
    Views:
    466
    Devin Jeanpierre
    Feb 14, 2012
Loading...

Share This Page