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条)

报告相同问题?

悬赏问题

  • ¥15 SQL Server下载
  • ¥15 python如何将动态的多个子列表,拼接后进行集合的交集
  • ¥20 vitis-ai量化基于pytorch框架下的yolov5模型
  • ¥15 如何实现H5在QQ平台上的二次分享卡片效果?
  • ¥15 python爬取bilibili校园招聘网站
  • ¥30 求解达问题(有红包)
  • ¥15 请解包一个pak文件
  • ¥15 不同系统编译兼容问题
  • ¥100 三相直流充电模块对数字电源芯片在物理上它必须具备哪些功能和性能?
  • ¥30 数字电源对DSP芯片的具体要求