Set Session Variable on Unload 
Author Message
 Set Session Variable on Unload

I'm new at ASP coding.

I need to set a session variable on an ASP page when the
page is unloaded. It doesn't seem to work so maybe someone
could show me another way to achieve this.

Thanks

Michael
ie.

<BODY BGCOLOR="silver" onUnload="ResetMyVar()">

..
..
<%
Sub ResetMyVar()
    Session("abc") = 0
End Sub
%>



Tue, 27 Jul 2004 13:40:42 GMT  
 Set Session Variable on Unload
I'm not exactly understanding, but,
What you call page is client side, and session variable is server side.
What you call unload seems to be *body_onunload* event in the page.
Now you need to redirect the *page* to another ASP page to do what you want
when the page is unloaded. It is impossible.
So if you're OK, using server side *session_onEnd* event you'll do your job.
In this case you write your code in global.asa file.
However *_onUnload* event is greatly different from *_onEnd* event.
I'm uncertain what you want with the event, so cannot say any more.
Add thread if you want more.


Quote:
> I'm new at ASP coding.

> I need to set a session variable on an ASP page when the
> page is unloaded. It doesn't seem to work so maybe someone
> could show me another way to achieve this.

> Thanks

> Michael
> ie.

> <BODY BGCOLOR="silver" onUnload="ResetMyVar()">

> ..
> ..
> <%
> Sub ResetMyVar()
>     Session("abc") = 0
> End Sub
> %>



Tue, 27 Jul 2004 13:56:40 GMT  
 Set Session Variable on Unload
you have some confusion about the fundamentals of ASP. you can't run ASP
in a page after it's been delivered to the client.

this will be very inelegant, but about the only way to do this, is to do
this with a new ASP page, which you then close(). pretty ugly effect.
can you manage without it, or set a cookie instead (this can be done by
javascript)

Atrax - MVP [Microsoft Most Valued Professional]

http://www.infinitemonkeys.ws/

Host with me for $100 a year!
http://www.atrax.ws/hosting/

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Tue, 27 Jul 2004 14:01:07 GMT  
 Set Session Variable on Unload
Maybe have a form with just a hidden field.
Then submit the form with the unload event
to an ASP page that sets the session variable.
But if they are leaving your site the session
goes awy, right?

<script language="VBScript">
Sub ResetMyVar()
    document.forms("formID").submit
End Sub
</script>

<BODY BGCOLOR="silver" onUnload="ResetMyVar">

<form id="formID" action="page.asp" method=POST>
<input type="hidden" name="something" value="?">
</form>
...
Then page.asp would be
<%
Session("abc") = 0
%>

gl,
Bill Wallace


Quote:
> I'm new at ASP coding.

> I need to set a session variable on an ASP page when the
> page is unloaded. It doesn't seem to work so maybe someone
> could show me another way to achieve this.

> Thanks

> Michael
> ie.

> <BODY BGCOLOR="silver" onUnload="ResetMyVar()">

> ..
> ..
> <%
> Sub ResetMyVar()
>     Session("abc") = 0
> End Sub
> %>



Wed, 28 Jul 2004 10:31:42 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. How to declare variables set in form proc but used after form unloaded

2. dotnet Session variable set too late - Error Page Description related

3. browser window size, set to a session variable?

4. Setting ASP Session variable

5. Setting a session variable from a href

6. Getting/Setting Session Variables from JavaScript

7. Can an onClick set a session variable?

8. setting session variables with dynamic identifiers?

9. Setting Session variable to List SelectedIndex

10. Request for Help: setting session variables using javascript.

11. browser window size, set to a session variable?

12. Setting ADO Recordsets as session variables

 

 
Powered by phpBB® Forum Software