如果禁用Cookie会发生什么? [英] What happens if cookies are disabled?

查看:1357
本文介绍了如果禁用Cookie会发生什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里相当基本的问题。在PHP中,如果用户的浏览器禁用了Cookie,则不能同时使用服务器cookie( $ _ SESSION )和客户端cookie( $ _ COOKIE setcookie )或只有后者被禁用?
基本上你不能让用户登录或做任何需要一个会话的东西,对吗?

Pretty basic question here. In PHP, if the user's browser has cookies disabled, you cannot make use of both server cookies ($_SESSION) AND client cookies ($_COOKIE, setcookie) or only the latter are disabled? Basically you can't make the user log in or do anything that requires a session, right?

另外,在这种情况下,有人想要有cookie禁用?

Also, in which case would someone want to have cookies disabled?

谢谢!

推荐答案

会话和正常Cookie都是正常的Cookie。如果用户不接受Cookie,则他不能使用他们启用的任何功能。这意味着几乎整个互联网将为该用户打破,这就是为什么在这个时代几乎没有人完全禁用Cookie。

Yes, it's true. Both sessions and normal cookies are normal cookies. If a user does not accept cookies, he cannot use any of the functionality enabled by them. Which means pretty much the whole internet would break for that user, which is why in this day and age there's virtually nobody who has cookies disabled entirely.

PHP有一个内置的,这种机制称为透明会话ID ,它会自动重写所有链接以在查询中包含会话ID参数。我不建议使用它,因为URL中的会话ID打开了一个全新的蠕虫病毒。

PHP has a built-in mechanism called transparent session ids, which automagically rewrites all links to contain the session id in a query parameter. I would not suggest using it, since session ids in the URL open up a whole new can of worms.

为了用户友好,我建议您测试用户已启用或未启用Cookie(设置Cookie,重定向到在网址中设置了Cookie 标记的下一页,查看您是否收到了Cookie),如果没有,请恳请用户以启用它们。

For user friendliness, I'd recommend you test whether the user has cookies enabled or not (set a cookie, redirect to the next page with a flag in the URL that cookies should be set, see if you get any cookies back) and if not, kindly advise the user to enable them.

这篇关于如果禁用Cookie会发生什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆