Jump to content

Recommended Posts

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

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.