简体   繁体   English

是否必须在http标头中设置cookie?

[英]Does a cookie have to be set in the http header?

Would like to set cookies from the server (CGI - C) 想要从服务器(CGI-C)设置cookie
Can it be set after the header has been printed? 可以在打印标题后进行设置吗?

Thanks. 谢谢。

Not directly, cookies that come directly from the server must be explicitly set in the response header using Set-Cookie . 不是直接,必须使用Set-Cookie在响应标头中显式设置直接来自服务器Set-Cookie See here for a thorough explanation. 请参阅此处以获取详细说明。

You can set cookies using JavaScript embedded in an HTML document, or via a few other mechanisms, such as Flash. 您可以使用嵌入HTML文档中的JavaScript或通过其他一些机制(例如Flash)来设置Cookie。

Other than that though, the header is the only place in HTTP you can set them. 除此之外,标头是HTTP中唯一可以设置的地方。

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

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