473,671 Members | 2,209 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

close user from site with clicking close button of browser

oranoos3000
107 New Member
hi
i,m writing a script for chat room
i,d like to with clicking close button of browser user is exited from site
meaning of this say is with clicking close button all of session variable
is removed from server
i wrote below code for this action
but sorry i failed
please help me
my base page code is as follows
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. session_start();
  3. $_SESSION['username']='sima';
  4. ?>
  5. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  6. <html>
  7. <head>
  8. <title>Untitled Document</title>
  9. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  10. <script type="text/javascript">
  11. function getData(source)
  12. {<!--119-->
  13.     var XMLHttpRequestObj=false;
  14.     if(window.XMLHttpRequest)
  15.     {    XMLHttpRequestObj=new XMLHttpRequest();}
  16.     else if(window.ActiveXObject)
  17.     {    XMLHttpRequestObj=new ActiveXObject("Microsof.XMLHTTP");}
  18.  
  19.     if(XMLHttpRequestObj)
  20.     {<!--131-->
  21.         XMLHttpRequestObj.open("GET",source);
  22.         XMLHttpRequestObj.onreadystatechange=function()
  23.         {<!--135-->
  24.             if(XMLHttpRequestObj.readyState==4 && (XMLHttpRequestObj.status==200 || XMLHttpRequestObj.status==0))
  25.             {<!--137-->
  26.             newWindow=window.open("show_users.php","new users");
  27.             newWindow.focus();
  28.             }<!--e137-->
  29.         }<!--e135-->
  30.     }<!--e131-->
  31.         XMLHttpRequestObj.send(null);
  32. }<!--e119-->
  33.  
  34. </script>
  35. </head>
  36.  
  37. <body onUnload="getData('exit.php');">
  38.  
  39. </body>
  40. </html>
  41.  
  42.  
code of exit.php is as follows
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. session_start();
  3. session_destroy();
  4. ?>
  5.  
Jan 9 '10 #1
1 1610
Dormilich
8,658 Recognized Expert Moderator Expert
have you tried window.onbefore unload?
Jan 9 '10 #2

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

Similar topics

4
5516
by: feng | last post by:
Hi, In our asp.net app, we need to capture the event when user close the browser window by clicking on the "x" button. But it doesn't seem to be as easy as it sound. Can someone show me how to do this? Thanks
20
2030
by: Harry | last post by:
My development environment is Framework 1.1, ASP.Net and IE 6.X. I have logout button in all the screens in the application. I am doing database activity when the user clicks on logout button. However the user can close the application using the IE close cross mark. When the user closes the application without logout button all my database routine and logout activities will not be called. Any solution for this kind of situation? Thanks...
1
2683
by: RJN | last post by:
Hi I have a pop-up window which has a task menu on its left which are nothing but links to different screens. This window also has a close button. On click of close button I do some server side operation and the window closes itself. Now the user can close the window by clicking on X(Top right corner) or by pressing Alt+F4 window. I want to atleast alert the user when he does these 2 things to inform he has not clicked on the close...
3
4258
by: Lord2702 | last post by:
Sat. Oct. 30, 2004 3:25 PM PT I want to detect, if user has close the browser, (after logging to my site), that user has closed the browser. How to achieve it ? I want to know this close action on my server-side code. Because if he logout by clicking on Logout/ Sign-Off button it simple to get the message. Although, this is very similar to the first above. Also, if user takes any action on client-side or browser side how will I detect...
0
1775
by: Vam$y | last post by:
In asp.net how to catch window close event when a user closes the window explicitly by clicking on “x” button which is on the right top corner of the browser. My requirement is When a user explicitly closes the window I need to pop up a message to user and log information in DB whatever the user entered in the form. I implemented on Body unload event by calling vb script, but it is getting executed when I go out of the form by...
0
1453
by: JP | last post by:
Is there a way to temporirly disable the X button (close) on a MODAL window in the web browser? We have cleanup code that needs to run after the user closes the modal window. This works fine if the user closes the window via a button I have placed on the page. If the user tries to close the window via the "X", then popup blockers potentially pervent then cleanup window from executing. Right now, clicking the X fires off the...
1
33148
by: nebulus | last post by:
I'm working on a web app that under normal circumstances will be happy with the Session_OnEnd event, but when a user leaves a page by closing the browser by either Alt+F4 or just hitting the "X", I'll need to kill the session. Now, with the onbeforeunload event, I can handle this quite easily in IE, but in FireFox, it's another matter. For one thing, FireFox seems to empty out its event object on a page unload, so it's very hard to track...
7
5815
by: Toccoa | last post by:
After considerable googling - I mean searching with Google(r) - I could not find javascript on a button or <a href=... to close a window in the latest versions of IE and FireFox. There seemed to be two techniques for earlier versions. But the window.opener='' ;window.close(); and the window.open('','_parent','') ;window.close(); techniques do not work for me. I.e., I still get confirmation message
15
3278
by: =?Utf-8?B?QmVuamFtaW4gSmFuZWNrZQ==?= | last post by:
Hi, we're struggling with a strange session problem in an ASP.NET 2.0 application. The application is used by our customers to access customer-related information such as invoices over the internet. Customer have to log-in and are then identified by their customer number and some other information stored in the session. We use the asp.net session cookie system to keep track of the sessions. This works quite well. Unfortunately though,...
0
8476
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, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
8393
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8914
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
7433
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 projectplanning, coding, testing, and deploymentwithout 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...
1
6223
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5695
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4406
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2810
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
1809
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.