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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Session Variable Removal

Status
Not open for further replies.

Nilgni

Instructor
Feb 21, 2002
58
US
I read about this and have tried setting the variable to a different value, erasing it, and erasing all. Nothing is working.

I am getting an error message on this page (object expected line 16)

I appreciate any help,
Keith

Code:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]

[b]<%
        Sub ResetMeetingID()
          
                      
                    
                    Session.Contents.Remove "sMeetingID"
                  
     
        
        End Sub
%>[/b]

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="refresh" content="3;URL=index.asp" />

<title>Untitled Document</title>

</head>

[b]<body onLoad="ResetMeetingID()">[/b]
</body>
</html>
 
The subroutine is in the server-side code.

The attempt to call the subroutine is in a client-side event.


Remember, by the time the browser gets the page the server is done with its work.
 
Thanks, that make sense. I was using an example that I found on W3C schools site:
Code:
Example 1

<%
Session("test1")=("First test")
Session("test2")=("Second test")
Session("test3")=("Third test")Session.Contents.Remove("test2")for each x in Session.Contents
 Response.Write(x & "=" & Session.Contents(x) & "<br />")
next
%>

If you could point me in the right direction on how to do this I would appreciate it.

Thanks Again
 
Not sure what happened but the code didn't display right. The line in bold is what I am trying to duplicate. Esentially I want to put a link that clears the session, than takes them to the page where they can enter it again.

Code:
<%
Session("test1")=("First test")
Session("test2")=("Second test")
Session("test3")=("Third test")

[b]Session.Contents.Remove("test2")for each x in [/b]

Session.Contents
 Response.Write(x & "=" & Session.Contents(x) & "<br />")
next
%>
 
if the session variable contains a value you can get rid of it like this:
[tt]Session("test3")= ""[/tt]

if you want to get rid of an object reference you could do:
[tt]Set Session("test3") = Nothing[/tt]

to nuke the entire session:
[tt]Session.Abandon[/tt]

 
You are running 2 lines into one.
Code:
Session.Contents.Remove("test2")for each x in

Session.Contents
 Response.Write(x & "=" & Session.Contents(x) & "<br />")
next
should be
Code:
Session("test2")=Nothing
For each x in Session.Contents
 Response.Write(x & "=" & Session.Contents(x) & "<br />")
next

___________________________________________________________
If you want the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
Steam Engine Prints
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top