Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passing a session variable

Status
Not open for further replies.
Dec 11, 2000
46
US
I can response.write the session variable on the first page where I declare it, but cant get it on the second page. Could somebody give me a clue as to what the problem could be?

'first page 24ProcAddEdit.asp
Session("sv24MEID") = strMEID
Response.Write Session("sv24MEID")


'second page
'Begin HOW DID WE GET HERE
If InStr(Request.ServerVariables("HTTP_REFERER"), "24ProcAddEdit.asp") Then
strQSMEID = Session("sv24MEID")
Response.Write "You came from 24"
Response.Write strQSMEID
Response.Write Session("sv24MEID")
ElseIf InStr(Request.ServerVariables("HTTP_REFERER"), "20AddNewME.asp") Then
strQSMEID =Request.QueryString ("MEID")
Response.Write "You came from 20"
Else
Response.Write "Where did you come from?"
strQSMEID = "793"
End If
'End HOW DID WE GET HERE
 
What is contained in the session variable and what output do you get on each of the pages?

BDC.
 
I was about to send you the rest of the code on the page and I started thinking about the Session.Abandon. I remarked it and it works fine now. OK problem solved, but why wont this work if the session.abandon is done before I set the new session variable? I guess the session.abandon is not nessesary if I am going to specifically reset the session variable to a new value. What would the proper way be to clear a session if I had to without affecting other sessions on the page?

Thanks

strMEID = "691"
strLoc = "444"

Session.Abandon

'Set required variables
adCmdText = 1

'Start building the SQL string
sql24 = "UPDATE tblEquipment SET tblEquipment.Location = " & strLoc & " "
sql24 = sql24 & " WHERE tblEquipment.MEID = " & strMEID & " ;"


Set oConn24 = Server.CreateObject("ADODB.Connection")'Open Connection
oConn24.Open strConnect

'Create the command object
Set oCmd24 = Server.CreateObject("ADODB.Command")

'Set the command object properties
Set oCmd24.ActiveConnection = oConn24
oCmd24.CommandText = sql24
oCmd24.CommandType = adCmdText

'Execute the command
oCmd24.Execute

Session("sv24MEID") = strMEID
Response.Write Session("sv24MEID")
'Response.Redirect "22AddEditMEPM.asp"

%>
 
To clear a session without using session.abandon try:

session("sessionname") = ""

BDC.
 
Or I think you can destriy the object by:

set session("sessionname") = nothing

BDC.
 
BDC2,

I actually was working with something similar to this today and was having a problem with the

set session("sessionname") = nothing

because it was expecting it to be an object (I kept getting an object expected error). I think you would have to set it = "" (like in your first post) in order for it to work. Hope that helps.

Everything is absolute. Everything else is relative.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top