mdmartiny Posted February 16, 2011 Share Posted February 16, 2011 I was wondering if there is away to set a logout message when you are using sessions this is my code <?php session_start(); if($_SESSION[auth] = "yes") { session_unset(); session_destroy(); header( "Location: index.php" ); exit(); } else { if ($_SESSION[auth] != "yes") { header( "Location: index.php" ); $_SESSION['error'] = "please login!"; exit(); } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/227840-logout-session-message/ Share on other sites More sharing options...
lastkarrde Posted February 16, 2011 Share Posted February 16, 2011 //if they are logging out etc.. $_SESSION['logout_message] = 'See ya'; //wherever you want to display the logout message if(isset($_SESSION['logout_message'])) { echo $_SESSION['logout_message']; } Quote Link to comment https://forums.phpfreaks.com/topic/227840-logout-session-message/#findComment-1174877 Share on other sites More sharing options...
mdmartiny Posted February 16, 2011 Author Share Posted February 16, 2011 I tried something like that and it did not work. After clicking on the link you are logged out Quote Link to comment https://forums.phpfreaks.com/topic/227840-logout-session-message/#findComment-1175013 Share on other sites More sharing options...
Far Cry Posted February 16, 2011 Share Posted February 16, 2011 Here is the bit of code I use on my website to log people out.... <?php session_start(); $user_name = $_SESSION['username']; $dbid = $_SESSION['userid']; ?> <script type='text/javascript'> function redirect(){ window.location = "index.php"; } </script> <?php if ($user_name){ session_destroy(); echo "<body onLoad=\"setTimeout('redirect();', 1);\">"; echo""<b>You hve been logged out...</b>; } else ?> Quote Link to comment https://forums.phpfreaks.com/topic/227840-logout-session-message/#findComment-1175052 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.