虽然是另一个项目php使用同一个session登录 [英] Although it's another project php uses the same session to login

查看:52
本文介绍了虽然是另一个项目php使用同一个session登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在有 2 个项目正在处理,但问题是因为我登录到一个项目,所以登录会话被保存,所以当我切换另一个项目时,我立即登录.

I've got 2 projects I work on right now, but the problem is that since I'm logged into one project the session for the login is saved so when I switch the other project I'm instantly logged in.

两个项目都在同一台服务器上运行,我将用户 ID 保存在会话中.

Both projects are running on the same server and I save the userID in the Session.

一旦我发布项目并拥有更多用户帐户,这就会出现问题.

This could get a problematic as soon as I publish the projects and have more user accounts.

推荐答案

如果您的两个项目都托管在相同的域名和端口下,那么就 PHP 和浏览器而言,它们都是一个应用程序,因此它们将共享单个会话.

If both your projects are hosted under the same domain name and port then as far as PHP and the browser is concerned it's all one application, and therefore they will share a single Session.

您是否在逻辑上将其视为两个项目与此无关.如果需要将它们分开处理,则分别托管它们,例如在不同的端口或子域上 - 您可以在本地网络服务器上执行此操作以进行开发/测试,也可以在实时服务器上执行此操作.

Whether you logically view it as two projects is irrelevant to that. If they need to be treated as separate then host them separately e.g. on a different port or a subdomain - you can do this on your local webserver for development / testing, as well as on the live server.

这篇关于虽然是另一个项目php使用同一个session登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆