简体   繁体   English

检查网站上是否存在Cookie

[英]Check if cookie exists on website

I'm trying to redirect my users of my website toa page if a certain session cookie exists. 如果存在某个会话cookie,我试图将我的网站用户重定向到页面。 The session cookie is from another website and called pubcookie_l. 会话cookie来自另一个网站,称为pubcookie_1。 How do I see if this cookie exists when on my website, perhaps checking in php? 在我的网站上(可能是在php中)时,如何查看该cookie是否存在? Thanks. 谢谢。

This is not possible. 这是不可能的。 You can not check some other domains cookie on different domain. 您无法在其他域上检查其他一些域cookie。

However you can check the Referer . 但是,您可以检查Referer If the referer is your university's website. 如果推荐人是您大学的网站。

In PHP Referer can be accessed by $_SERVER['HTTP_REFERER'] variable. 在PHP中,可以通过$_SERVER['HTTP_REFERER']变量访问Referer。

Cookies don't exist "on the website", they exist on the client. Cookies不存在于“网站上”,而是存在于客户端上。 And the client doesn't (shouldn't) give any cookies to a domain that didn't set it. 并且客户端不会(不应)向未设置它的域提供任何cookie。

If it did, that would be a huge security risk (cookies often contain passwords or other sensitive information, even though they shouldn't), not to mention privacy concerns. 如果确实如此,那将带来巨大的安全风险(Cookie通常包含密码或其他敏感信息,即使它们不应该包含密码或其他敏感信息),更不用说隐私了。

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

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