473,325 Members | 2,774 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,325 software developers and data experts.

How to delete sessions before closing a window ??

window.onbeforeunload = confirmExit;
function confirmExit()
{
if (needToConfirm)
{
return "You have attempted to leave this page. If you have made any changes to the fields without clicking the Save button, your changes will be lost. Are you sure you want to exit this page?";
}
}

Above Code is the java scrpt code which i am using before closing a window.

Problem::
How to delete sessions before closing a window ??

I place a Logout Button but when we close the window with out clicking the Logout Button i want to end his session .

How is it possible??

Please give the code for that..thanks in advance
Nov 30 '06 #1
2 3210
cassbiz
202 100+
The O'Reilly book gives some great tips on session_destroy()

http://www.oreilly.com/catalog/webdb...pter/ch08.html
Nov 30 '06 #2
cassbiz
202 100+
Here is the code that is given as an example

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.   // Only attempt to end the session if there 
  3.   // is a $PHPSESSID set by the request.
  4.   if(isset($PHPSESSID)) {
  5.     $message = "<p>End of session ($PHPSESSID).";
  6.     session_start(  );
  7.     session_destroy(  );
  8.   } else {
  9.     $message = "<p>There was no session to destroy!";
  10.   }
  11. ?>
  12. <!DOCTYPE HTML PUBLIC 
  13.    "-//W3C//DTD HTML 4.0 Transitional//EN"
  14.    "http://www.w3.org/TR/html4/loose.dtd" >
  15. <html>
  16.   <head><title>Sessions</title></head>
  17.   <body>
  18.     <?=$message?>
  19.   </body>
  20. </html>
  21.  
Nov 30 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

22
by: Theo | last post by:
Question for the group The authentication system for the site Im working on seems to function properly and all is good. A session keeps track of everything and a cookie is used to accept or deny...
3
by: Colin McKinnon | last post by:
Hi all, The title says it all - I'm doing sessions with cookies. I can divide the data within the session easily enough but I can't see when the user creates a new window or closes an old one. ...
10
by: Tom Szabo | last post by:
Is there an event when that triggers when the window is closing.... I am talking about when the user clicks on the cross on the right top corner of the window!!!
5
by: Ron L | last post by:
I have an MDI application with a number of child windows. In each child window I am catching the Closing event and having the child window decide if it should set cancel to true. The intent here...
1
by: Chris Bruce | last post by:
In my application I need a way to distiguish between the following events: 1. When a user closes an MDI child window. 2. When the user closes the MDI parent window which subsequently closes the...
10
by: newbie | last post by:
My application_end event in global.asax is not working as-is. In order to debug, I want to call it from another file, say debug.aspx through a button, e.g. "end application". How do I call...
2
by: Tom | last post by:
How is the best way to avoid validation when closing a window? For instance, I have a Windows Forms window which has a validation event for a text box. However, if one enters invalid data in then...
2
by: Cesar Ronchese | last post by:
Hello, I'm experiencing a very weird problem. I have a ASP.Net 2005 application (VB.Net) that creates some folders to store temporary files. example: Session_Start(...)...
4
by: =?Utf-8?B?UmljaA==?= | last post by:
On a form - I have a datagridview which is docked to the entire form. The datagridview allows users to Delete and/or Add Rows. On the Form_Load event I Fill the datagridview source table with a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.