473,386 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How can I prevent Sessions from ending just because the browser window is closed

Hi Gang,

I would like to have my application retain sessions even after the user
closes their browser window, up unil the time the session is supposed
to time out. Right now if the user closes IE their session is
re-created. Is there any way around this?

Thanks,
Christian Blackburn

Jun 16 '06 #1
8 1846
What do you mean by 're created'?

If the user closes the browser, nothing happens to their session. The
session will continue to be around until timeout.

I don't know what you mean by the session being recreated when the user
closes the browser.

"Christian Blackburn" <ch*****************@Yahoo.com> wrote in message
news:11*********************@g10g2000cwb.googlegro ups.com...
Hi Gang,

I would like to have my application retain sessions even after the user
closes their browser window, up unil the time the session is supposed
to time out. Right now if the user closes IE their session is
re-created. Is there any way around this?

Thanks,
Christian Blackburn

Jun 16 '06 #2
"Christian Blackburn" <ch*****************@Yahoo.com> wrote in message
news:11*********************@g10g2000cwb.googlegro ups.com...
I would like to have my application retain sessions even after the user
closes their browser window, up unil the time the session is supposed
to time out.
That's right.
Right now if the user closes IE their session is re-created.
Of course it is. IIS has no means of knowing that a browser has been closed.
Is there any way around this?


A way round what? This is standard behaviour.
Jun 16 '06 #3
Hi Marina,

Thanks for your reply.

Marina Levit [MVP] wrote:
What do you mean by 're created'?
When a user logs into my website, the site populates their session with
their access credentials. I then record that the user is logged in by
placing their session in the database (is deleted automatically when
their session times out via Global.asax). This is to prevent
simultaneous logins.

Once they close the browser window, even for two seconds if they go
right back and try to view the website a new session is assigned and
they're unable to log in, because as far as the website knows their
session is already in use.
I don't know what you mean by the session being recreated when the user
closes the browser.


Once they go back to the page the website gives them a new session ID.
Thanks for your help,
Christian Blackburn

Jun 17 '06 #4
Hi Mark,

Thanks for your reply.
Mark Rae wrote:
I would like to have my application retain sessions even after the user
closes their browser window, up unil the time the session is supposed
to time out.
That's right.


That true the session is retained, but if they close their browser
within the 15 minute timeout period and go back to the site they'll
actually wind up with a different session entirely. That's exactly
what I don't want to happen.
Right now if the user closes IE their session is re-created.
Of course it is. IIS has no means of knowing that a browser has been closed.


That's true IIS doesn't, but their cookie-based session should be
retained or at least there should be some setting I can enable to make
it so.
Is there any way around this?


A way round what? This is standard behaviour.


In my opinion standard behaviour and logical behaviour are often at
odds especially with buggy software.

Cheers,
Christian Blackburn

Jun 17 '06 #5
"Christian Blackburn" <ch*****************@Yahoo.com> wrote in message
news:11**********************@c74g2000cwc.googlegr oups.com...
A way round what? This is standard behaviour.


In my opinion standard behaviour and logical behaviour are often at
odds especially with buggy software.


I can't help that...

Imagine the scenario of an Internet Café...

User 1 fires up Internet Explorer, goes to your site (or HotMail or
whatever) and does what they need to do.

When they've finished, they close the browser, inadvertently forgetting to
click the Logout button.

User 2 takes the seat recently vacated by User 1, fires up Internet Explorer
and goes to your site.

How on earth can your site or ISS or anything else for that matter tell at
that moment whether User 1 is back having just made a quick visit to the
coffee machine and therefore connect to User 1's pervious session, or
whether User 2 has just connected and therefore create a new session?
Jun 17 '06 #6
You may set a cookie on the client machine. Also set a time out limit
(say 2 minutes). Now if a user closes the window, and get to your site
again, this cookie will give you the last session id and you can
manipulate your code accordingly.

Yanesh Tyagi
Christian Blackburn wrote:
Hi Marina,

Thanks for your reply.

Marina Levit [MVP] wrote:
What do you mean by 're created'?

When a user logs into my website, the site populates their session with
their access credentials. I then record that the user is logged in by
placing their session in the database (is deleted automatically when
their session times out via Global.asax). This is to prevent
simultaneous logins.

Once they close the browser window, even for two seconds if they go
right back and try to view the website a new session is assigned and
they're unable to log in, because as far as the website knows their
session is already in use.

I don't know what you mean by the session being recreated when the user
closes the browser.

Once they go back to the page the website gives them a new session ID.
Thanks for your help,
Christian Blackburn

Jun 17 '06 #7
"Yanesh Tyagi" <ya**********@qualtech-consultants.com> wrote in message
news:O1**************@TK2MSFTNGP03.phx.gbl...
You may set a cookie on the client machine. Also set a time out limit (say
2 minutes). Now if a user closes the window, and get to your site again,
this cookie will give you the last session id and you can manipulate your
code accordingly.


And what if this is a shared public computer...?
Jun 17 '06 #8
Hi Mark and Yanesh,

The way mark is describing it is correct. The timeout doesn't work
like that. It's a session cookie, that will timeout either when the
browser is closed or when the timeout ocurrs whichever is first.

Cheers,
Christian

Jun 21 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Simon | last post by:
Hi Folks, Any help here would be much appreciated. i have a page session_write.php /////////////////// session_start(); $_SESSION = 'AAA'; print("sA". $_SESSION);
1
by: Onur Bozkurt | last post by:
I want to ask the user if he/she is sure when he/she wants to close the browser window. And I want to cancel the event if she is not sure. I know this is possible, but I couldn't write the right...
2
by: Mike May | last post by:
Hi IE6 Win2k The javascript FAQ describes how you can retain a reference to a window that you have opened and manipulate the window - focus on it or close it, viz: 4.10 How do I check to...
4
by: bbass | last post by:
thanks to all that replyied to my previous post with the following code in question: <a href="merc.htm" target="_new_merc" onfocusout=window.close class="left_link"> i understand that the...
9
by: Daniel Walzenbach | last post by:
Hi I am faced with the following problem: I have a page (let’s call this page page1.aspx) containing some TextBoxes and a hyperlink which opens another page (let’s call this page page2.aspx)...
7
by: tarun.kataria | last post by:
Hi All, Is there any way to detect that the user is trying to Xout the browser window instead of hitting a button. Because in my application I want to make it sure that they dont do it either...
21
by: alistair_henderson | last post by:
Morning All, I have some code for a website which uses 'window.open' to simulate modal dialog boxes. I use the window.closed property to decide if the window object exists at various points. ...
3
by: sophie_newbie | last post by:
Hi, I have a cgi script that performs a very long computation that can take several hours to complete. Is there any smart way that I can keep this script running until it is finished (after the...
1
paulrajj
by: paulrajj | last post by:
Hi, I am working on my project which is a chat online script using php and javascript. I am maintaining users online_status who gets logged in to chat through session and updating their status to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.