dongzhuohan7085 2011-05-15 23:43
浏览 55
已采纳

禁用Cookie时会话数据不显示

I'm pretty new to PHP and am experimenting with cookies and sessions.

So, in IE, if I set my Privacy settings to Block All Cookies, obviously all cookies will be blocked but what about sessions?

I ask because I am under the impression that if cookies are blocked but I start a session, the session should be valid. In other words, whatever I set for the session variable should stick with the browser for as long as the browser is open but this does not seem to be happening.

My whole thought process behind this is that I could use a cookie as my first means of tracking and in addition to setting the cookie I could also set a session in case cookies are disabled.

So question 1 - Why is my session variable getting blocked? Is that suppose to happen? question 2 - Is it good practice to set both a cookie and a session (in case the cookie is blocked)?

  • 写回答

3条回答 默认 最新

  • dongsong73032 2011-05-15 23:49
    关注

    Sessions are for the most part, just an identifier linked to a data set, per user.

    This identifier is almost always stored as a cookie. If cookies are disabled, so are session cookies, so are sessions. The way round this is to include the session ID in every URL, and then pick it out and use it to initialise the session (ie. use the ID to find the stored session data).

    PHP can automatically add the session ID to relative URIs, it depends on configuration options though. See "Passing the Session ID" in the manual. (Pay particular attention to this comment.)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 远程桌面文档内容复制粘贴,格式会变化
  • ¥15 关于#java#的问题:找一份能快速看完mooc视频的代码
  • ¥15 这种微信登录授权 谁可以做啊
  • ¥15 请问我该如何添加自己的数据去运行蚁群算法代码
  • ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”
  • ¥15 网络设备配置与管理这个该怎么弄
  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题