PHP 中的无 Cookie 会话
对于我的项目的(奇怪的)要求之一,我想使用无 cookie 会话。同时,“session.use_trans_sid”无法打开:(
有人请告诉我是否还有其他出路吗?
谢谢 马尼什
For one of my project's (weird) requirements, I want to use cookie less sessions. At the same time, "session.use_trans_sid" can not be turned on :(
Does anybody please let me know if is there any other way out ??
Thanks
Manish
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
创建一个自定义会话管理器,根据 IP 地址和用户代理以及其他识别因素(因为 IP+UA 可能不是也可能不会是唯一的)来识别用户。另一个(丑陋的)解决方案是通过手动(如果是小站点)或使用隐藏表单(非标准)向每个链接添加会话标识符 GET 参数来自己实现 use_trans_sid 功能。
Make a custom session manager that identifies the user based on, for example, IP address and user agent and other identifying factors (as IP+UA might not and probably will not be unique). Another (ugly) solution is to just implement the use_trans_sid functionality yourself by adding a session identifier GET parameter to every link by hand (if it's a small site) or with a hidden form (that's non-standard).
如果您确实想要没有 cookie 的会话,您可以随时手动将 SID 放入您的所有 URL 中。人们过去经常这样做。 :-)
If you really want sessions without cookies, you can always put the SID in all your URLs manually. People used to do this quite a bit. :-)
唯一的其他选择是将会话数据保留在客户端上,并通过每个请求将其在服务器之间来回传递,尽管从技术上讲,这将是无会话架构。
这意味着对于 GET,每个链接都必须重写以包含所有会话变量,对于 POST,它们必须作为隐藏字段包含在内。
The only other option is to keep the session data on the client and pass it back and forth to and from the server with each request, although technically that would be a sessionless architecture.
That means that for GETs each link has to be rewritten to include all the session variables, and for POSTs they have to be included as hidden fields.