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

Session variable...

Status
Not open for further replies.

TPetersonFlorida

Programmer
Aug 8, 2003
76
US
How can I set a session variable when a page unloads??
 
try this in the body tag
onbeforeunload="location.href='/asp/asp_page_to_set_session_var.asp'"

then in that page set the seession var and then direct the user to a "proper" page
 
Here is the scenario:

I have a pop up window where the user can click on two buttons BUT the user can also click the X in the upper right corner to close the window out. If the user does that then i need to be able to capture some event to set a session variable. The "location.href" thing did not work. Is there some way i can set a session variable from a VB Script on the page itself??

PLEASE I NEED HELP !!!
 
So you have already an popup window.
Make another asp page that do your job, lets say set_session.asp

place this on your popup window
<body onunload=&quot;doUnload()&quot;>
...

<script language=javascript>
function doUnload()
{
x=window.open(&quot;set_session.asp&quot;,&quot;_new&quot;,&quot;width=1,height=1,toolbar=0,top=0,left=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0&quot;);
}
</script>

and in your set_session.asp file
<%
'asp code here
%>
<script language=javascript>
self.close()
</script>

I've used this for all my pages. works 100% unless they use some popup stopers or some kind of things.

________
George, M
 
well i have another way. when the page loads set the session to the value of No (ie the value that will be set if the No button is clicked or the X button is clicked). if the user clicks yes then no problem. otherwise also u have ur session...

Known is handfull, Unknown is worldfull
 
Shaddow: excellent!!! that worked even though i have a slight &quot;blip&quot; when that other window opens. i'll take it though!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top