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
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
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
Share on other sites

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.