Jump to content

Destroy PHP Session via JavaScript


BCAV_WEB

Recommended Posts

Currently I have a Javascript button to close a tab window which is great, but annoying problem is when the user opens up the section again all the previous session errors are there.

 

I have tried the following, which didnt work;

 

[

function destroy()

{

window.open('destroyCode.php');

}

 

<a href='javascript:window.close()' onclick="destroy()" ><img class='close' src='images/close.jpg' alt='Close Window' /></a>

 

]

 

[

 

<?php

session_unregister("add_customer_errors");

session_unregister("add_customer_form");

session_destroy();

?> 

<html>

<body onload="javascript:window.close()">

</body>

</html>

 

]

 

Any ideas of how to do it? I have got the session being unregistered if the data is correct and saved to the database. But what is the user wants to start and then changes there mind.

Link to comment
Share on other sites

Sorted it, turns out I had to start the session on that page to close the session's I wanted to close. Thanks for the help  :D

 

[

<?php

session_start();

session_unregister("add_customer_errors");

session_unregister("add_customer_form");

?>

<html>

<body onload="javascript:window.close()">

</body>

</html>

]

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.