简体   繁体   English

保存每个用户的php会话ID

[英]Save php sessions id per user

I'm trying to save a session per user in the server. 我正在尝试在服务器中保存每个用户的会话。

The objetive is doing this without using cookies in the local store of user. 对象在不使用用户本地存储中的cookie的情况下执行此操作。

If the user clicks on remember me, the server will save the session of a user y even if the browser was closed, thus, the user will still be logged in. 如果用户单击“记住我”,则即使关闭浏览器,服务器也将保存用户y的会话,因此该用户仍将登录。

I tried to avoid a database with SessionHandler but I do not know how to do it. 我试图避免使用SessionHandler建立数据库,但是我不知道该怎么做。

Can someone explain to me how can I save the session on the server? 有人可以向我解释如何将会话保存在服务器上吗?

You need cookies if you want the user's session to be remembered after a browser close. 如果要在浏览器关闭后记住用户的会话,则需要Cookie。

Do you mean you want to use localStorage to save the id? 您是否要使用localStorage保存ID? Honestly, I'm not sure how that's much different then storing a cookie or if it would work. 老实说,我不确定与存储cookie或它是否起作用有什么不同。 If you try to use localStorage, when the user logs in you would want to store the session id generated by PHP using JS. 如果您尝试使用localStorage,则在用户登录时,您想存储由PHP使用JS生成的会话ID。 You would want also to enable session.use_trans_sid=1 so it'll pass the session id in the URL. 您还希望启用session.use_trans_sid=1以便它将会话ID传递到URL中。

You haven't posted any code but when you do maybe we can help you more when you get stuck. 您尚未发布任何代码,但是当您这样做时,也许我们会在遇到困难时为您提供更多帮助。

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

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