Jump to content

Ending login session


otamendi

Recommended Posts

 

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.

Link to comment
https://forums.phpfreaks.com/topic/61503-ending-login-session/
Share on other sites

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;
}

Link to comment
https://forums.phpfreaks.com/topic/61503-ending-login-session/#findComment-306201
Share on other sites

 

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.

 

Link to comment
https://forums.phpfreaks.com/topic/61503-ending-login-session/#findComment-306878
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.