473,659 Members | 2,996 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Session destroy when closing browser

Hi all,

After a visitor has loged in, a session is started.
The session is destroyed after the visitor clicked "Log out'.

When the visitor forgets to log out and closes the browser immediately, the
session stil exists because when the visitor opens the browser again and
comes back to the site he/she is still loged in.
Ofcourse i don't want that.
I want the session to be destroyed when the visitor closes the browser
immediately.

Is there a way to destroy a session when the user closes the browser and
forgets to log out.

If instead of php, javascript is necessary, please tell me also.

T.i.a.

Best regards,
Tino Wintershoven.
The Netherlands
Jun 2 '08 #1
3 13898
T. Wintershoven wrote:
Hi all,

After a visitor has loged in, a session is started.
The session is destroyed after the visitor clicked "Log out'.

When the visitor forgets to log out and closes the browser immediately, the
session stil exists because when the visitor opens the browser again and
comes back to the site he/she is still loged in.
Ofcourse i don't want that.
I want the session to be destroyed when the visitor closes the browser
immediately.

Is there a way to destroy a session when the user closes the browser and
forgets to log out.

If instead of php, javascript is necessary, please tell me also.

T.i.a.

Best regards,
Tino Wintershoven.
The Netherlands
In your php.ini file, set the value:

session.cookie_ lifetime=0

Or, before EVERY session_start() call, use:

session_set_coo kie_params(0);
--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===

Jun 2 '08 #2
Jerry Stuckle escribió:
>Is there a way to destroy a session when the user closes the browser
and forgets to log out.
[...]
In your php.ini file, set the value:

session.cookie_ lifetime=0

Or, before EVERY session_start() call, use:

session_set_coo kie_params(0);
Apart from this, note that session data still exists on server; it will
be deleted eventually, when next "garbage" collection happens. In
general, the server has no way to know that you've closed the browser.
Usually, that's not an issue*, just be aware of it.
(*) It's an issue when you're paranoid about hackers using someone
else's session ID
--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://bits.demogracia.com
-- Mi web de humor al baño María: http://www.demogracia.com
--
Jun 2 '08 #3
Álvaro G. Vicario wrote:
Jerry Stuckle escribió:
>>Is there a way to destroy a session when the user closes the browser
and forgets to log out.
[...]
>In your php.ini file, set the value:

session.cookie _lifetime=0

Or, before EVERY session_start() call, use:

session_set_co okie_params(0);

Apart from this, note that session data still exists on server; it will
be deleted eventually, when next "garbage" collection happens. In
general, the server has no way to know that you've closed the browser.
Usually, that's not an issue*, just be aware of it.
(*) It's an issue when you're paranoid about hackers using someone
else's session ID

If you're that paranoid about hackers, you should be using https protocol.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===

Jun 2 '08 #4

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

Similar topics

3
18468
by: Pete | last post by:
I have a site which is using sessions to pass data from one page through to the next. The problem that I have is that there are only two places where the session could/should be destroyed. This is where a form is printed using : <input type="button" name="Button" value="Print Order" onClick="window.print();"> or when the order form is reset using a JavaScript function :
4
19073
by: megha | last post by:
Hi I am writing a program in JSP which requires user to log in and as he logs in database was updated with his status on and till the user does not sign out no other user with same login and password can enter in the system. as he signs out database was updated but the problem is if somehow he forgot to sign out and closed the browser or navigate to other page or site his information was still on in the database. I want a solution how...
14
4060
by: Darrin J Olson | last post by:
I am trying to end a session for a site without having to completely close the browser to end it. When I access the site and log in it works fine. If I log out and in with a different account without closing the browser, I get the first session's information. Also, if a open another browser and log in with a different account I get the session from the first browser. I've tried deleting all cookies and any cached pages, but still get the...
4
2858
by: Al | last post by:
Is possible to terminate all session variable created without closing the browser I do not want users to click on BACK button on browser or paste the url link in the http:// and shows the record displayed after logout. This works fine if users close the Browser.
2
2416
by: Nate Spillson | last post by:
I have an asp.net web application that uses session variables to store user information (username, security areas, configuration data). When the user logs into the system I store all of this information in a class and then dump it into a session variable. The timeout on the server is set to 2hrs. Every now and then (5min-30min) the web server will lose the session variable. This is very inconsistent and doesn't appear to have an associated...
2
2671
by: RC | last post by:
hi, I now got a session ID. I want to try to resume a session by closing the current browser and open a new one. Then pass the session ID in URL query string on new browser to resume the session that is running at the closed browser. Is it possible to resume a session like that? Any sample code provided?
0
3231
by: joseph conrad | last post by:
Hi, I tried to implement my own session handler in order to keep control on the process the drawback I foun it is not creating and storing in my cookie the PHPSESSID variable anymore. reading te documentation it seems it should do it anyway any advice?
8
1831
by: Mantorok | last post by:
Hi I've just been told that closing your browser closes your session on the web-site you are viewing, is this true? If so, is this the browser that initiates the closure, or the server? Thanks Kev
3
6779
by: Amar | last post by:
Hi all, I want to use a cookie that will destroy after closing the browser, in my application. I am able to destroy my cookie after log out,but don't know how to destroy this when I will close the browser. Please help me. Amar
0
8428
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8851
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8747
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8528
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8627
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7356
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2752
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1737
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.