dongtanliefang8765 2018-04-09 07:25
浏览 6

PHP会话重合! 一个人可以在没有登录的情况下以另一个人身份打开网站

I have a website with a login. The script was working for months now. but since a week We noticed when we opened the website it's already logged in by someone else.

Users Can't Log out too sometimes

This issue became very common now. It's happening all the time. Sometimes users aren't able to login. When they do they sometimes end up in the account of the previously logged in account.

We used php SESSIONS to implement login.

//Login

//Step 1 Facebook Login
//Step 2 Check db or add to db
//Step 3 below

$_SESSION['logouturl'] = $logouturl;
$_SESSION['loggedin'] = true;
$_SESSION['user_data'] = $user_data;
header("Location: $url");

Here is the logout script:

//logout
session_start();
session_destroy() ;
if(isset($_GET['redirect']) && !empty($_GET['redirect']))
{
    $url=$_GET["redirect"];
}
else {
    $url="http://www.website.com/";
}
header("location:$url");

I figured out this is some issue with the internal working of php sessions.

UPDATE : Thank you to everyone who helped!!

No, we did not find a solution to the problem. The customer was using a reseller hosting. maybe it's gotta do something with the configuration when one site affects the other one.

We set up a new hosting and installed the same script there. Everything is fine and life's good!

  • 写回答

2条回答 默认 最新

  • dsio68964998 2018-04-09 07:34
    关注

    You should use session_start(); at login and session_destroy(); during logout.

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化