Good day!
I am having a little problem regarding clearing sessions.
I have a link named LOGOUT in php.. when this link is click, I want to clear and detroy all sessions and redirect the user to index.php page.
thank you for helping!
Good day!
I am having a little problem regarding clearing sessions.
I have a link named LOGOUT in php.. when this link is click, I want to clear and detroy all sessions and redirect the user to index.php page.
thank you for helping!
There's a function that clears session variables for you: session_destroy().
Also, the function header() will let you redirect to any page. E.g.
header("Location: index.php");
how to put in in click event of the link?
You don't want to put it as an onclick event, as that's a bit more complicated and assumes that the user has JavaScript. I'd suggest making a file that destroys the session and redirects the user. This is all you need (I'm not even sure you need to add session_start(), but it doesn't hurt):
<?php
session_start();
session_destroy();
header("Location: index.php");
?>
Tnx for this...it helps!
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.