linux - cookie 是如何工作的

标签 linux http cookies curl

我正在尝试通过curl发送post请求,所以我运行了

curl --cookie /tmp/cookies.txt --cookie-jar /tmp/cookies.txt --data "name=value" http://www.mysite.com > post_request.txt 

我将在 chrome 控制台中找到的 cookie 存储在/tmp/cookies.txt 中。后者有一个名称和一个值。我应该使用特定的格式在/tmp/cookies.txt 中写入 cookie 参数吗? (因为我只输入了值并没有起作用)

最佳答案

查看 curl 的手册页它说:

The file format of the file to read cookies from should be plain HTTP headers or the Netscape/Mozilla cookie file format.

查找您找到的 mozilla 格式:

http://xiix.wordpress.com/2006/03/23/mozillafirefox-cookie-format/

<domain> <TRUE|FALSE> <PATH> <TRUE|FALSE> <TIMESTAMP> <NAME> <VALUE>

(制表符分隔)

Domain: the domain that set & can subsequently read the cookie. This could include subdomains, e.g., .google.com means that local.google.com, news.google.com, whatever.google.com could possibly read the cookie, based on the next flag.

Flag: either TRUE or FALSE, whether or not all machines under that domain can read the cookie’s information.

Path: the root path under the domain where the cookie is valid. If this is /, the cookie is valid for the entire domain.

Secure Flag: either TRUE or FALSE, whether or not a secure connection (HTTPS) is required to read the cookie.

Expiration Timestamp: the “Unix Time” in seconds when the cookie is set to expire.

Name: the name of the value that the cookie is storing/saving.

Value: the value

(当然,您也可以仅使用所述的纯 HTTP header 。)

关于linux - cookie 是如何工作的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14429616/

相关文章:

http - WebDAV 属性即使在设置之后也会在请求中返回

javascript - Cookies - 跨多个域设置

linux - 使用 gstreamer 合并音频和视频管道

linux - 在特定目录的特定文件中使用 find 和 grep

amazon-web-services - 从响应中删除 AWS/EC2 状态文本

javascript - 如何处理 ETIMEDOUT 错误?

java - 使用 GET 重定向的 JSoup cookie 处理

asp.net-mvc - 所需的防伪 cookie "__RequestVerificationToken"不仅存在于 Google Chrome 中

c - 为什么ssh登录时会调用两次pam_sm_authenticate?

linux - usb-skeleton.c 不工作