Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2007

    Unanswered: session variable disappearing

    hi there. i'm trying to troubleshoot some code (that i didn't write...)
    it's an ASP web application that includes a menu that is built dynamically. One of the links on the menu is to "logout".
    as you can see in the line below, this link posts to the login page, with the logout variable set to true.

    Response.write "['Log out " & Session("UserID") & "', 'http://cserver/ds/login.asp?logout=true
    When the logout variable is set to true, one of the things that happens is a record is written to an audit log. what's happening is that a session variable called UserID is being wiped out at some point... but i can't figure out where or why.

    The function that uses this information looks like:

    function AuditGetUName(user_id)
    Dim rsUser
    set rsUser = Server.CreateObject("ADODB.Recordset")
    rsUser.ActiveConnection = gConnection
    rsUser.Source = "SELECT Uname FROM Users WHERE ID = " + CStr(Session("UserId"))
    rsUser.CursorType = 0
    rsUser.CursorLocation = 2
    rsUser.LockType = 3
    I've tried the following:
    1. login - test to ensure that the UserID field is populated.
    2. when dynamically building the logout option in the menu, i've included the session userid to prove that its still there.
    3. when logging out, i've added some debug lines that print out the values of user_id, Session("UserId") and also CStr(Session("UserId")) and they all show the right value...
    until i call the method which is when it fails with the error:

    Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

    [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'ID ='.
    In case you're wondering how i tested this, i just added a response.end right before calling the .open method. when i do that, along with response.writes for the session variable, i can see that everything is actually ok...

    finally, if i open the logout link in a new window, it works fine!??
    any tips would be appreciated.

  2. #2
    Join Date
    Mar 2003
    The Bottom of The Barrel
    Provided Answers: 1
    Based on #3 above, I'm suspect of something in your query itself.

    What do you get for rsUser.Source after assigning the SQL? Can you successfully run it in QA/SSMS?
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  3. #3
    Join Date
    Nov 2003
    Christchurch, New Zealand
    What happen if you response.write the rsUser.Source property just before the rsUser.Open and have a response.end after it.

    Try something like this...

    rsUser.Source = "SELECT Uname FROM Users WHERE ID = " + CStr(Session("UserId"))
    rsUser.CursorType = 0
    rsUser.CursorLocation = 2
    rsUser.LockType = 3
    response.write rsUser.Source
    response.write CStr(Session("UserId"))

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts