dongzilu0178 2016-02-26 05:38
浏览 20
已采纳

由一个项目创建的会话也可以由PHP中的其他项目访问

In one of my project on localhost a session is created for user login. It is stored in $_SESSION['uname']. My some other project is also using the same session name variable. The problem is when I already have logged into my first project admin area and then I go to my other project admin area, it doesn't ask me to enter credentials to login window; instead it directly takes me to the admin panel. I know this is happening due to the use of same $_SESSION['uname'] in my various projects. So I am wondering how we can force other project to display log in window although I have already logged into my first project?

It might also possible that my other project has some different login credentials but I will never offer me login screen if I have already logged into my first project.

I am also thinking that how the professional websites keep their session name unique so that other can never use it? In my case the session name is accessible everywhere.

  • 写回答

4条回答 默认 最新

  • dongmen9517 2016-02-26 06:01
    关注

    Looks like you are using localhost for every projects in your local.

    1. Create separate VirtualHost for each project, then session will be unique for each project - as the cookie's domains are different.
    2. If you want to keep localhost (I'd not recommend), you should think about namespace for session of each project, like $_SESSION['project1']['uname']
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度