otamendi Posted July 24, 2007 Share Posted July 24, 2007 Hi, whenever a user logins into the control panel of my script correctly i do this: session_start(); $_SESSION['login'] = 'superuser'; Then on the site to check if the user is login i use: <?php session_start(); if(!(array_key_exists('logeado',$_SESSION) && $_SESSION['logeado'] == 'superuser')) { die; } //end if ?> I need a code to put on a php page to end the session and put a link to it inside the panel so if the user clicks it then press the back button he cannot go back and see the control panel. thanks for the help. Quote Link to comment Share on other sites More sharing options...
otamendi Posted July 24, 2007 Author Share Posted July 24, 2007 ops sorry on the second code is ' login ' instead of ' logeado ' but i still need the answer, thanks. Quote Link to comment Share on other sites More sharing options...
DeadEvil Posted July 24, 2007 Share Posted July 24, 2007 you need a log-out process page, inside that page put unset($_SESSION['login']); header('location: panel....'); exit; Quote Link to comment Share on other sites More sharing options...
OnlyLeif Posted July 24, 2007 Share Posted July 24, 2007 If you do not want a seperate site for the logout, use: <a href="samepage.php?logout">Log-out</a> <?php if (isset($_GET['logout'])){ session_unset(); session_destroy(); header("Location: index.php"); exit; } ?> Quote Link to comment Share on other sites More sharing options...
OnlyLeif Posted July 24, 2007 Share Posted July 24, 2007 If you will use my previous post, remember to use the php above all other printing (because of the header () command) Also, if you don´t want to redirect the user after logging out, you can always use a button. and the php to a html button exekvation is: if (isset(['submit'])) { session_unset(); session_destroy(); exit; } Quote Link to comment Share on other sites More sharing options...
otamendi Posted July 25, 2007 Author Share Posted July 25, 2007 Hi, the first attempt showed: Warning: session_destroy() [function.session-destroy]: Trying to destroy uninitialized session in /home/xxx/admin/exit.php on line 3 Warning: Cannot modify header information - headers already sent by (output started at /home/bolsa/public_html/admin/salir.php:3) in /home/xxx/admin/exit.php on line 4 The next attempt using what DeadEvil said didn't show any errors but it didn't work when i press the back button and use the control panel still works. thanks. Quote Link to comment Share on other sites More sharing options...
DeadEvil Posted July 25, 2007 Share Posted July 25, 2007 it should be work... make sure you have a session_start(); at the top of your panel page and logout process page. Quote Link to comment 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.