Ajax Talk - Asynchronous javascript and xml discussion board
 FAQ   Search    Usergroups      Register   Profile   Check your messages   Log in 
Signup now to enjoy a range of free membership advantages !!
Ajax Talk - Moderators Wanted
calling logout.php on body unload to destroy session

 
Post new topic   Reply to topic    Ajaxtalk.com Forum Index -> AJAX Help
View previous topic :: View next topic  
Author Message
vinpkl
New one
New one


Joined: 22 Nov 2008
Posts: 2

PostPosted: Sat Nov 22, 2008 10:16 am    Post subject: calling logout.php on body unload to destroy session Reply with quote

hi all

i have my logout.php which destroys sessions and session ids on click of logout. I want to have same effect means i want to call this logout.php script when the user closes the "browser tab".

as these are the days of "browser tabs" so this is very important for me.

when the user closed the whole browser or logout then all session and session ids are destroyed automatically but these sessions are not destroying when the user closes the "browser tab".

I have tried ajax also but not able to get the result as i m not much in ajax. So it would be great if somebody helps me with calling my logout.php script on closing "browser tab".


This is ajax script
Code:

<script type="text/javascript">
function ajaxFunction()
{
var xmlHttp;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    catch (e)
      {
      alert("Your browser does not support AJAX!");
      return false;
      }
    }
  }
  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
      document.myForm.time.value=xmlHttp.responseText;
      }
    }
  xmlHttp.open("GET","customer_logout.php",true);
  xmlHttp.send(null);
  }
</script>



This is my customer_logout.php script

Code:

<? require_once("config.php");
$unique_id = session_id();
session_regenerate_id();
$qry="delete from cart_table where unique_id='$unique_id'";
mysql_query($qry);
$_SESSION = array();
session_unset();
session_destroy();
header("Location:index.php");
?>


This is i calling ajax in html
Code:

<body onunload="ajaxFunction()">


vineet
________
maryjane


Last edited by vinpkl on Tue Feb 01, 2011 7:59 pm; edited 1 time in total
Back to top
View user's profile Send private message
sak
New one
New one


Joined: 31 Dec 2008
Posts: 2
Location: Madurai

PostPosted: Wed Dec 31, 2008 1:04 pm    Post subject: Reply with quote

so far as i know it is not possible in PHP .net only has this fantastic facility..but be hope world php users will find a fine solution take care
_________________
do it now... S.A.K
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic    Ajaxtalk.com Forum Index -> AJAX Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
 Advertisements
 XML & Copyright Notice 
    


Powered by phpBB © 2001, 2005 phpBB Group

What is according to Wikipedia: Ajax Web2.0 XML E4X


Link to our site:

  


del.icio.us digg spurl wists simpy newsvine blinklist furl blogmarks yahoo! myweb smarking ma.gnolia segnalo reddit fark technorati cosmos


Normal Bookmark


Partner Button Links:
Codecrunch.com: Webmaster Tutorials    One Ajax


Partner Text Links:
quomon | web20log | ajaxmatters | tableless | 456bereastreet | music charts | gift ideas | competitions | free xbox 360 | link trade ?


Credits:
it consultancy & project management lead generation zoekmachine optimalisatie steal these buttons seo expert