Cookie File Format

Source: Internet
Author: User
Tags filetime format definition

Reference: http://blog.csdn.net/lixianlin/article/details/2738229

1. essence of cookie files

Cookies are actually part of the content transmitted between the Web server and the client (typically a browser) during interaction. The content can be arbitrary, but it must be within the allowed length range. The client will save it on the local machine (for example, ie will save it in a local TXT file ),ProgramManage expired cookies. When a client accesses a webpage in a directory in a domain, the valid cookie information that is stored locally and belongs to the corresponding directory under that domain is attached to the header of the webpage request and sent to the server.

2. Cookie file storage location

Different clients have different cookie storage methods and locations. Here we only talk about the location of IE cookie files in windows.

In Windows 2000/XP, cookies are stored in the C: \ Documents ents and Settings \ <username> \ cookies \ directory by default (<username> here is the username used to log on to the system for you, enter cookies to open the directory. The naming rule is <username >@< domain>. TXT.

Different from 2000/XP, in Windows 95/98/Me, cookie files are stored in the c: \ windows \ cookies \ directory by default.

3. Cookie File Format

IE's cookie file is actually a TXT text file, but the line break is marked as a Unix line break Mark (0x0a). Because notepad is incompatible with the Unix line feed mark, it seems inconvenient to open all the content in one line, we can open it with editplus or UltraEdit-32, and then we will see the following content:
Name
Value
Domain/
1600
1263382784
30020896
452781968
30020892
*
Description of each line:

English description:
Line Summary
1 The variable name
2 The value for the variable
3 The website of the cookie's owner
4 optional flags
5 The most significant integer for expired time, In filetime format
6 The Least Significant integer for expired time, In filetime format
7 The most significant integer for creation time, In filetime format
8 The Least Significant integer for creation time, In filetime format
9 The cookie record delimiter (A * character)

Chinese description:
Cookie variable name in the first line
Cookie variable value of the second line
The third line is the domain to which the cookie variable belongs, such as csdn.net/javasblog.csdn.net/or blog.csdn.net/lixianlin/
The fourth line is an optional flag (Is Coke encrypted ?)
The upper integer of the cookie expiration time in filetime format.
Row 6: The low integer of the cookie expiration time (in filetime format)
The seventh line is the high integer of the cookie creation time (filetime format ).
Row 8: The low integer of the cookie creation time (in filetime format)
Line 9 cookie record delimiter (an asterisk *)

In addition, the domain of the cookie variable in the third row, such. It must be noted that.

Attached filetime format definition:
Typedef struct _ filetime {
DWORD dwlowdatetime;
DWORD dwhighdatetime;
} Filetime, * pfiletime, * lpfiletime;

The cookie file is a pure text file with the line break (ASCII = 10) as the Separator
You can use tstringlist to read data.
The format is as follows:

A_cookie
0.123
My. Demo. Site
1600
1589052800
30634450
672816768
29899592
*

Where
1st behavior cookie name
The first row is the cookie value.
Row 3rd is the address of the site to which the cookie belongs.
Row 4th is a flag value (Note: it should be accurate to indicate whether the cookie is encrypted)
5th low behavior timeout (Cardinal/DWORD)
6th high behavior timeout time
7th low level of behavior Creation Time
8th high behavior Creation Time
The fixed row 9th is *, indicating the end of a section.
Note that the time used here is not Delphi's tdatetime, but filetime (the corresponding tfiletime in D)
A file may contain multiple sections, which can be recycled in the preceding format.

Appendix VC ++ 6.0 resolution timeCode:

 01. # include "stdafx. H "02. # include "windows. H "03. 04.int main (INT argc, char * argv []) 05. {06. filetime ft; 07. ft. dwlowdatetime = 1263382784; 08. ft. dwhighdatetime= 30020896; 09. 10. systemtime st; 11. 12. filetimetosystemtime (& ft, & St); 13. 14. printf ("% 04d-% 02d-% 02d % 02d: % 02d: % 02d \ n", St. wyear, St. wmonth, St. wday, St. whour, St. wminute, St. wsecond); 15. 16. return 0; 17 .} 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.