?

Log in

No account? Create an account
 

Session Variables - Web Developer

About Session Variables

Previous Entry Session Variables Feb. 20th, 2005 @ 07:37 pm Next Entry
My ASP application uses several session variables. If the user exits properly - by using the in browser controls then they will clear (using session.abandon) and all will be good.

The problem is that there is a single HTML form with a javascript menu that remains open. If the user does not exit through the controls I have given them, but x's out of the browser, and then goes back in to the application - the session variables still exist.

I'm trying to figure out how/where I can clear these variables. I can't do it when the form loads because it reloads many times, and I need to keep the session variables. I can't put it in the HTML menu page either, because that one never reloads.

Any ideas/suggestions?

Thanks!
Leave a comment
[User Picture Icon]
From:rush2112
Date:February 21st, 2005 03:17 am (UTC)
(Link)
Well first of all, why is the menu in a sep. page? Wouldn't combining them both solve your problem and be better design?
[User Picture Icon]
From:valkyri
Date:February 21st, 2005 04:25 am (UTC)
(Link)
Generally I would do that, and get blasted for it by the resident developer (I'm on contract, he's an employee) but in this case, it's the way it has to work. It's just a menu program and it calls a lot of different modules. Anyhow, it'd take me a long time to explain, but it is that way for a good reason.

Do you have a solution?
[User Picture Icon]
From:valera
Date:February 21st, 2005 03:57 am (UTC)
(Link)
You're saying that when the browser is closed - the session vars remain? I don't think that could be .. the case.
[User Picture Icon]
From:valkyri
Date:February 21st, 2005 04:28 am (UTC)
(Link)

I have a page, call it default.htm and it contains a menu script only. From that menu, all the modules of the program are linked.

The menu calls the parent of the default.asp page, it spawns a child, and if the child is closed by x-ing out of the browser rather than closing it through the application then the session variables remain because the menu window is still open.

Whether you think it could be the case or not, it most certainly is the case. I have a list of employees, and it doubles if you open it again from the menu. I can't have that, and I have to clear those variables.

It wouldn't happen too often, but it potentially could happen, so I must have a fix.

Any ideas?
[User Picture Icon]
From:valkyri
Date:February 21st, 2005 04:29 am (UTC)
(Link)

Sorry, forgot to mention that the parent is closed when the child is opened. It is not open, but the menu remains.
[User Picture Icon]
From:valera
Date:February 21st, 2005 04:31 am (UTC)
(Link)
I don't remember the exact javascript syntax, but there is something like a window.onClose event that gets triggered when a window (i'm assuming the spawned child is a pop-up, right?) is closed. you could catch that and call another asp page.. wherever you want, to clear the session vars.
[User Picture Icon]
From:valkyri
Date:February 21st, 2005 04:33 am (UTC)
(Link)

Hmm.. good idea. I'll give it a try, thanks!
[User Picture Icon]
From:valera
Date:February 21st, 2005 04:34 am (UTC)
(Link)
no prob, hope it helps. just google for the javascript onclose event =)
[User Picture Icon]
From:ctpeko3a
Date:February 21st, 2005 07:26 am (UTC)
(Link)
OnClose would not fire if you close IE with Ctrl-W...

The best choice for your problem would be:

1. Put some kind of random number in your parent menu's caller of your page - if number would not match to existing session you will need to clear that session's vars.

2. Set time out for session vars to a shorter period. I don't remember where to set it in ASP but it's fairly easy to program.
(Leave a comment)
Top of Page Powered by LiveJournal.com