PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
$var
Forum Contributor
Posts: 317 Joined: Thu Aug 18, 2005 8:30 pm
Location: Toronto
Post
by $var » Fri Jan 27, 2006 11:46 am
if you have a session based on a cookie.. so like:
Code: Select all
$id = $_COOKIE['ID01'];
if ($_SESSION['IDO1'] != $id) {
header("Location: index.php");
}
how do i make a text link, not a button to log out, or destroy the session?
Last edited by
$var on Fri Jan 27, 2006 12:49 pm, edited 1 time in total.
shiznatix
DevNet Master
Posts: 2745 Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:
Post
by shiznatix » Fri Jan 27, 2006 12:03 pm
im not sure what you are saying. do you want to destory the session with a link? if so just make a link to logout.php and make logout.php look like this
Code: Select all
session_start();
$_SESSION = array();
session_destroy();
header("Location: index.php");
die();
$var
Forum Contributor
Posts: 317 Joined: Thu Aug 18, 2005 8:30 pm
Location: Toronto
Post
by $var » Fri Jan 27, 2006 12:16 pm
yah, okay... that'd be fine... i was just wondering if you could do it without having the go to another page.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Fri Jan 27, 2006 12:30 pm
Just a word of warning, the cookie may not be destroyed on some browsers when hitting a
header() redirected page..
$var
Forum Contributor
Posts: 317 Joined: Thu Aug 18, 2005 8:30 pm
Location: Toronto
Post
by $var » Fri Jan 27, 2006 12:40 pm
hmm... but if i clear the session on the index.php, would that work, if it didn't clear the first time with the header, it should the second right?
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Fri Jan 27, 2006 12:42 pm
the session data will be cleared, I'm simply saying the session id cookie may not. Which can be perfectly fine if you no longer have hooks related to that id anywhere.