Help - Search - Member List - Calendar
Full Version: Delete of cookies and of the session-id
WorkTheWeb Forums > Webmaster Resources > PHP Help
Support our Sponsors!
Matthias Braun
Help!

I try to delete at the end of the php-session either the cookies or the
sessionid (depending on cookies are allowed or not):

<?php
ini_set('session.use_trans_sid',1);
session_start();
unset($_SESSION['PHPSESSID']);
setcookie('PHPSESSID',FALSE,0);
?>

but it doesn't work. Who can help?

Thanks,

Matthias

Janwillem Borleffs
Matthias Braun wrote:
QUOTE
I try to delete at the end of the php-session either the cookies or
the sessionid (depending on cookies are allowed or not):


It doesn't work that way, because a new PHPSESSID is created each time you
call session_start().

When your goal is to logout a user or something like that, you should unset
an identifier, e.g. ``loggedin'':

session_start();
if ($logout) {
unset($_SESSION['loggedin']);
}


JW

Denis WERNERT
You may delete the session variables using session_destroy.
If you need a more complex behavior, you may overload the session handler
to gain full control over session handling.

Matthias Braun wrote:

QUOTE
Help!

I try to delete at the end of the php-session either the cookies or the
sessionid (depending on cookies are allowed or not):

<?php
ini_set('session.use_trans_sid',1);
session_start();
unset($_SESSION['PHPSESSID']);
setcookie('PHPSESSID',FALSE,0);
?

but it doesn't work. Who can help?

Thanks,

Matthias



PHP Help | Linux Help | Web Hosting | Reseller Hosting | SSL Hosting
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2005 Invision Power Services, Inc.