0

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!

2
Contributors
4
Replies
5
Views
5 Years
Discussion Span
Last Post by blocker
0

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");
?>
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.