如何与 php 应用程序共享会话

发布于 2024-09-04 12:48:27 字数 112 浏览 2 评论 0原文

我有一个 django 博客项目和一个 PHP 聊天项目。

我需要与 PHP 中的聊天共享登录 django ( request.user.id ) 的用户的 id。

这可能吗?

I have a django blog project and a chat in PHP.

I need to share the id of the user logged in django ( request.user.id ) with the chat in PHP.

Is this possible ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

一枫情书 2024-09-11 12:48:27

我认为以这种方式使用会话不是一个好主意,因为它们旨在为应用程序中的特定用户临时保存数据。将 id 存储在 cookie 中并在聊天中读取它,或者在链接中传递变量可能是更好的主意。

I don't think using sessions in this way is a good idea, since they're designed to keep data temporarily for a certain user in an application. It might be a better idea to store the id in a cookie and read that in the chat, or pass a variable in the link.

彼岸花ソ最美的依靠 2024-09-11 12:48:27

您可以为此使用 HTTP 身份验证。只要两个应用程序位于同一域中,并且两个应用程序的领域名称(在 WWW-Authenticate 标头中发送)相同,一旦用户登录到一个或另一个应用程序,REMOTE_USER 变量将可供两个应用程序使用,并将包含登录者的用户名。

You could use HTTP authentication for this. As long as both applications are on the same domain and the realm name (sent in the WWW-Authenticate header) is the same for both, once a use logs into one or the other application, the REMOTE_USER variable will be available to both and will contain the username of the person logged in.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文