简体   繁体   English

在本地主机上,两个不同的项目共享同一个会话

[英]On localhost, two different projects share the same session

My localhost is XAMPP.我的本地主机是 XAMPP。 The two projects are basically the same code, at least the login module.两个项目代码基本一致,至少是登录模块。 The projects are built with Codeigniter.这些项目是使用 Codeigniter 构建的。

My problem is, for example, if I logged in on Project A, then I found I'm automatically logged in on Project B, too.我的问题是,例如,如果我登录了项目 A,那么我发现我也自动登录了项目 B。

The two projects does not use the same database, but their login code is the same.这两个项目使用的不是同一个数据库,但是他们的登录代码是一样的。 When the user visit the page, I will check the variable $this->session->isLoggedIn first, if so, I will redirect the page to the user page.当用户访问页面时,我会先检查变量$this->session->isLoggedIn ,如果是,我会将页面重定向到用户页面。 I do find that they use the same session id.我确实发现他们使用相同的会话 ID。 Is this a common issue on the localhost, since they share the same domain, or I made a mistake?这是本地主机上的常见问题,因为它们共享同一个域,还是我犯了错误?

while set session you need to differentiate the session Based on project for your identification like this在设置session您需要像这样根据项目differentiate session以进行识别

$this->session->set_userdata('project_A_username', 'usernamehere');

and

$this->session->set_userdata('project_B_username', 'usernamehere'); . .

php session is common for all your project . php session 对你的所有项目都是通用的。 so you have to differentiate.所以你必须区分。

OP comments : If so, this will not happen in the live environment, since they are not under the same domain? OP评论:如果是这样,这不会发生在live环境中,因为它们不在同一个域下?

yes it will not happen .since they are in different domain .是的,这不会发生。因为它们在不同的域中。

run $ php artisan config:cache on both projects在两个项目上运行 $ php artisan config:cache

this usually happens on apache on windows这通常发生在 Windows 上的 apache 上

its explained here https://github.com/laravel/framework/issues/19454它在这里解释https://github.com/laravel/framework/issues/19454

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 与两个laravel 5项目共享相同的上传目录 - share same uploads directory with two laravel 5 projects 寻找两个项目的原因,laravel上的不同文件夹指向本地主机上的相同网站 - Looking for reason of two projects with different folder on laravel pointing to same website on localhost 如何在两个不同的域中共享PHP会话 - How to share PHP session in two different domains 我可以为两个Laravel项目进行相同的会话吗? - I can have the same session for two Laravel projects? 如何在同一域中的两个CodeIgniter应用程序之间共享会话 - How to share session between two CodeIgniter applications in same domain 在一台服务器的两个不同域上共享来自数据库的 codeignit 会话 - Share codeigniter session from database on two different domain in one server 在Codeigniter项目之间共享会话存储 - Share session storage between codeigniter projects 是否可以为两个不同的项目显示相同的地址URL或主页URL - Is it possible to show same address url or Home url for two different projects Laravel,2个领域的2个项目同一会议 - Laravel, 2 projects in 2 domains same session 具有相同导出数据的两个不同视图(LocalHost和WebServer) - Two different view with same exported data (LocalHost and WebServer)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM