session_destroy as logout
Moderator: General Moderators
session_destroy as logout
hy guys..
i use session_destroy for a logout script... and i use logout.php and then redirects to index.php
if im in a form.php and i apply a logout it doesn't unset all sessions in form.php if a return to form.php will have all sessions as normal this is normal...
how can i resolve this ??
i use session_destroy for a logout script... and i use logout.php and then redirects to index.php
if im in a form.php and i apply a logout it doesn't unset all sessions in form.php if a return to form.php will have all sessions as normal this is normal...
how can i resolve this ??
humm
ok my logou.php located at "/"
but i have a form.php in /forms/apf/form.php where for example its stores $_SESSIONS as user going to page1, page2 when finish it produces a session_destroy in form.php...
but if i for example in page2 i decide to click logout, executes /logout.php and then redirects to index.php located at main dir "/" if i return to my /forms/apf/form.php my forms still have my $_SESSIONS as previous posted...
ok my logou.php located at "/"
Code: Select all
setcookie("CINTRA", $_COOKIE['CINTRA'], time()-5184000);
session_destroy();
//ob_end_flush();
header("location: /");but if i for example in page2 i decide to click logout, executes /logout.php and then redirects to index.php located at main dir "/" if i return to my /forms/apf/form.php my forms still have my $_SESSIONS as previous posted...
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
Using header redirection can short circuit the transmission of any other headers, often does. Call session_write_close() before calling header(), which should fix it.
didn't resolve...
this session_write_close says:
i dont want to store any data i need to destroy everything..
i have tried with a Meta tag didn't resolve to... strange because if i execute session_destroy() in form.php it destroy all $_SESSION's... it sounds like if session_destroy not being call in the same dir or the same file don't destroy $_SESSION's from other scripts or dirs
i want to to the logout.php as it is... what can i do... ??
this session_write_close says:
Code: Select all
End the current session and store session datai have tried with a Meta tag didn't resolve to... strange because if i execute session_destroy() in form.php it destroy all $_SESSION's... it sounds like if session_destroy not being call in the same dir or the same file don't destroy $_SESSION's from other scripts or dirs
i want to to the logout.php as it is... what can i do... ??
Code: Select all
<?
setcookie("CINTRA", $_COOKIE['CINTRA'], time()-5184000);
session_destroy();
session_write_close();
//ob_end_flush();
header("location: /");
?>You got to empty the SESSION array and destroy the cookie
Code: Select all
setcookie("CINTRA", '', 0);
$_SESSION = array();
session_destroy();didn't work to.. i do a logout
like http://localhost/logout.php when i return to http://localhost/forms/apf/form.php and i still have my all $_SESSION'S variables, after in logout.php i have destroy the session and empty the array
like http://localhost/logout.php when i return to http://localhost/forms/apf/form.php and i still have my all $_SESSION'S variables, after in logout.php i have destroy the session and empty the array
Code: Select all
<?
setcookie("CINTRA", $_COOKIE['CINTRA'], time()-5184000);
$_SESSION = array();
session_destroy();
session_write_close();
//ob_end_flush();
header("location: /");
?>No you don't.AGISB wrote:You got to empty the SESSION array
duk - try this:
Code: Select all
<?php
//logout.php
setcookie('CINTRA', '', time()-3600);
session_write_close();
header('Location: http://www.yourdomain.com/index.php');
?>Alternatively, look at http://uk.php.net/manual/en/function.se ... andler.php
i cant understand... and im sure that the script form.php is not getting any information from database because for example, i have input another name: duk, then i do my logou i return to the page and it show me duk as name... and should appear blank.
this form.php is 3000 and some lines its why i didn't put here yet but if someone wants to see i put...
im thinking in something in the same page as form.php <body onUnload="javascript:logout();">
where logout to the session_destroy() in the same page...
this form.php is 3000 and some lines its why i didn't put here yet but if someone wants to see i put...
Code: Select all
<?
setcookie("CINTRA", '', time()-3600);
session_write_close();
header("location: http://localhost/index.php");
?>where logout to the session_destroy() in the same page...
omg, i found why was doing that.
was missing session_start()
noob... but no one saw it to lol, and because the redirection was being maded i never saw the error.
was missing session_start()
Code: Select all
session_start();
setcookie("CINTRA", '', time()-3600);
session_destroy();
//session_write_close();
header("location: http://localhost/index.php");- Maugrim_The_Reaper
- DevNet Master
- Posts: 2704
- Joined: Tue Nov 02, 2004 5:43 am
- Location: Ireland