0

我有一个具有多个用户级别的系统,当一个用户登录然后在同一个浏览器上另一个用户登录时,我想注销现有用户。我不知道该怎么走..这是我的代码:

ob_start();
session_start();
require_once('../db/db_connection.php');
$user_session=$_SESSION['username'];
$user_s_q=mysql_query("select userlevel from users where  username='$user_session'");
$se_row=mysql_fetch_array($user_s_q);
    $level=$se_row['userlevel'];


if(empty($_SESSION['username'])&& empty($_SESSION['userLevel'])){
    header("location:../index.php");
    }

    elseif($level!='admin'){

        header("location:../index.php");
        }
   elseif($level>1){

       //logout the existing user

      }

    else{
       //display content

          }

我怎样才能做到这一点?有什么帮助吗?

4

1 回答 1

0

You'll want to destroy the old session:

session_regenerate_id(TRUE);
$_SESSION=array();

Or use the example on the php manual for session_destroy (http://php.net/manual/en/function.session-destroy.php)

于 2013-07-21T03:29:40.213 回答