If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > session variable disappearing

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-22-11, 15:24
chubbypama chubbypama is offline
Registered User
 
Join Date: Jul 2007
Posts: 50
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.

Code:
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:

Code:
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
rsUser.Open
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 rsuser.open method which is when it fails with the error:

Quote:
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.
Reply With Quote
  #2 (permalink)  
Old 02-23-11, 14:59
Teddy Teddy is offline
Purveyor of Discontent
 
Join Date: Mar 2003
Location: The Bottom of The Barrel
Posts: 6,075
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? ***
Reply With Quote
  #3 (permalink)  
Old 03-09-11, 17:13
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
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...

Code:
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"))
response.end
rsUser.Open
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On