简体   繁体   English

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

[英]How to share a session with a php application

I have a django blog project and a chat in PHP. 我有一个django博客项目和一个PHP聊天室。

I need to share the id of the user logged in django ( request.user.id ) with the chat in PHP. 我需要与PHP中的聊天共享共享django(request.user.id)登录的用户的ID。

Is this possible ? 这可能吗 ?

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. 最好将ID存储在cookie中并在聊天中读取它,或者在链接中传递变量。

You could use HTTP authentication for this. 您可以为此使用HTTP身份验证。 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. 只要两个应用程序都在同一个域上,并且两者的领域名称(在WWW-Authenticate标头中发送)都相同,则一旦用户登录到另一个应用程序,REMOTE_USER变量将对两个应用程序都可用,并且包含登录用户的用户名。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM