CaptainChainsaw Posted July 27, 2008 Share Posted July 27, 2008 Hi all, I've got an irritating problem which is probably needs an easy fix. I have a "logoff.php" script which I simply want it to kill the session and display a message to the user saying that they have been successfully logged out. The problem is that when I click the "log off" link it produces no message to the user unless the the page is refreshed. Here's my code: <? session_start(); session_destroy(); include('header.php'); require('/home/vol4/byethost12.com/b12_2105146/htdocs/smarty/Smarty.class.php'); require_once('class.conf.php'); $conf=new conf(); $smarty = new Smarty(); $smarty->template_dir = $conf->getConfItem('template_dir'); $smarty->compile_dir = $conf->getConfItem('compile_dir'); $smarty->cache_dir = $conf->getConfItem('cache_dir'); $smarty->config_dir = $conf->getConfItem('config_dir'); if(!$_SESSION['username']){ $smarty->assign('loggedoff', 'You have been sucessfully logged off.'); $smarty->display('logoff.tpl'); } include('footer.php'); ?> Any ideas? Thanks again for any help on this one. CC Link to comment https://forums.phpfreaks.com/topic/116855-solved-destroying-sessions/ Share on other sites More sharing options...
unkwntech Posted July 27, 2008 Share Posted July 27, 2008 What does the 'link' to this page look like? Link to comment https://forums.phpfreaks.com/topic/116855-solved-destroying-sessions/#findComment-600887 Share on other sites More sharing options...
Nhoj Posted July 27, 2008 Share Posted July 27, 2008 Try taking out the if conditonal statement; if(!$_SESSION['username']){ and simply display the message without it. More than likely the $_SESSION['username'] variable still exists until the next page load. You could also simply do: session_destroy(); unset($_SESSION['username']) However the 1st example would probably be best. Link to comment https://forums.phpfreaks.com/topic/116855-solved-destroying-sessions/#findComment-600889 Share on other sites More sharing options...
CaptainChainsaw Posted July 27, 2008 Author Share Posted July 27, 2008 Nhoj, thanks for the tip, I used your first suggestion, worked a treat! Link to comment https://forums.phpfreaks.com/topic/116855-solved-destroying-sessions/#findComment-601009 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.