2013-06-27 124 views
-1

問題是,當用戶登錄該用戶試圖在同一個瀏覽器相同/ DIFF憑據它正在接受重新登錄後...限制多個用戶登錄,在同一個瀏覽器

我相同/不同勢憑證不知道在哪裏我一直錯了..

這裏是loggedin.php

 <?php 

    header("Cache-Control: private, must-revalidate, max-age=0"); 
    header("Pragma: no-cache"); 
    header("Expires: Fri, 4 Jun 2010 12:00:00 GMT"); 

    include('GenericClasses/GenericCollectionClass.php'); 
     include('Models/UsersModel.php'); 
     include('DataObjects/Users.php'); 
     include('DatabaseAccess/DBHandler.php'); 

     session_start(); 

     if(!isset($_SESSION['user'])) 
    { 
    header('Location: LoginViewController.php'); 
    exit(); 
    } 
    echo '"<div style="background:white; text-align:right"> Login as:'.$_SESSION['user'].' 
    <a href="LogoutViewController.php" style="text-align:right">Logout</a></div>"'; 
    $username=$_SESSION['user']; 
    $model = new UsersModel(); 

    $result = $model->checkUserid($username); 
    $_SESSION['id']=$result; 
    echo '<div style="background:white; text-align:right;">'.$_SESSION['id'].'</div>'; 

    ?> 

任何建議是可以接受的...

+0

聽起來像一個會話\ cookie的問題,但不可能告訴基於這意味着你需要提供 – 2013-06-27 04:32:21

+0

@Dagon信息loginindex代碼也是...... –

+0

您可以嘗試檢查會話是否已啓動,只有在未啓動時才啓動。使用此檢查代碼:http://stackoverflow.com/questions/6249707/check-if-php-session-has-already-started並將session_start代碼放在裏面。 – Gimmy

回答

0

我得到的答案我疑問句重刑....

這是基於在LoginViewController.php會話[用戶]重定向用戶的代碼,它的工作很好..

1)始終放置在session_start代碼()頂部。 ..

<?php 
     session_start(); 

      include('GenericClasses/GenericCollectionClass.php'); 
      include('Models/UsersModel.php'); 
      include('DataObjects/Users.php'); 
      include('DatabaseAccess/DBHandler.php'); 
      if(!empty($_SESSION['user'])) 
      { 

      header("Location:loggedin.php"); 
      die(); 
      } 
      else 
      { 
     ?> 
     //Html code for login page 
     <?php 
      } 
      ?> 

這裏是Loggedin.php代碼..

   <?php 
        session_start(); 
       header("Cache-Control: private, must-revalidate, max-age=0"); 
       header("Pragma: no-cache"); 
       header("Expires: Fri, 4 Jun 2010 12:00:00 GMT"); 

       include('GenericClasses/GenericCollectionClass.php'); 
       include('Models/UsersModel.php'); 
       include('DataObjects/Users.php'); 
       include('DatabaseAccess/DBHandler.php'); 


     if(!isset($_SESSION['user'])) 
     { 
     header('Location: LoginViewController.php'); 
     exit(); 
     } 
     echo '"<div style="background:white; text-align:right"> Login as:'.$_SESSION['user'].' 
    <a href="LogoutViewController.php" style="text-align:right">Logout</a></div>"'; 


     ?> 
相關問題