Simple Logout Session link
Moderator: General Moderators
-
fariquzeli
- Forum Contributor
- Posts: 144
- Joined: Mon Jun 24, 2002 9:16 am
- Location: Chicago
- Contact:
Simple Logout Session link
What's the easiest and best way to create a simple link that ends the session and logs the user out?
I always had a logout.php page that logged the user out, then redirected to my index.php page.
Code: Select all
<?php
session_destroy();
header("Location: index.php");
?>-
fariquzeli
- Forum Contributor
- Posts: 144
- Joined: Mon Jun 24, 2002 9:16 am
- Location: Chicago
- Contact:
- RandomEngy
- Forum Contributor
- Posts: 173
- Joined: Wed Jun 26, 2002 3:24 pm
- Contact:
Actually:
If the session isn't continued first, PHP won't know what session to destroy, and it won't work. I've tested this myself.
Code: Select all
<?php
session_start();
session_destroy();
header("Location: index.php");
?>