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
https://forums.phpfreaks.com/topic/218837-destroy-php-session-via-javascript/
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>

]

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.