php - 如果浏览器不支持 cookie,PHP 如何维护会话?
问题描述
今天我在采访中被问到
如果浏览器不支持 cookie,PHP 如何维护会话?
选项是....
1. using an MD5 hash of the user's email address as the session identifier
2. using the browser's network address as the session identifier
3. including the session identifier as a parameter every GET and POST request
4. using the "secure cookie" header to force the browser to set a cookie
谁能告诉我哪个是准确的,请给出一个简短的解释?
解决方案
正如我们在评论中讨论的那样 - 2 个答案有意义,2 个没有意义。
- 完全依赖于会话,所以它不起作用。
- 会工作,但同一网络中的人将共享相同的会话。
- 是另一种会话可以工作的方式,但是如果您共享 url,则会发生与 2nd 相同的错误。
- 一个明显的诱饵答案。
建议的答案是 2 和 3 组合(如果只能选择一个,则为 3),在 URL 中存储由带有 unix 时间戳的 IP 地址标识的会话,以区分用户。
推荐阅读
- javascript - 检查jquery中的复选框
- mongodb - 提高性能并了解 IOPS 和 MongoDB 游标的使用
- python - python 一班轮拆分,执行操作,转换为列表
- python - CSV 数据:如何制表和管理
- typescript - 如何使用 Typescript 在 Material-UI 中自定义主题?
- python - 创建了新的 DataFrame 列,无符号最小值小于零
- node.js - pm2 以编程方式读取指标
- c# - 如何模拟 PolicyResult 以包含 FinalException 的值?
- php - 命令行 php 使用 apache2 php.ini 文件中的值;为什么?
- javascript - 无法在 WebView React Native 中设置自定义字体