Cookie's establishment
Cookies is a mechanism for web servers in client storage and return information.
This simple, permanent and client-based state letter
The interest rate expands the ability of the web-based client / server application. Therefore, it is widely used in a large number of practical.
For example, all subscribers subscribed to Microsoft's MSDN, access to Borland Online, and the home stores accessed
Cookie provides the last record of the last visit to the next visit.
Delphi 3 is a visualization, an object-oriented high-efficiency fast application development tool (RAD), which is launched by Borland, 1997.
A large number of latest features, such as developing COM / DCOM, one-step development ActiveX object, multi-layer database application Midas, etc., and use
Delphi 3 develops a web server-based program, such as ISAPI / NSAPI, Win-CGI, and CGI programs are very convenient.
Developing a Web Server program using Delphi 3 is very simple, convenient, because of Web Module in Delphi,
A large number of objects such as TWEBApplication, TwebRequest, TwebResponse, TPAGEPRoducer is available. For
Cookie
Delphi3 also provides a lot of programs for use
Such like TwebResponse.cookies, Twebresponse.SetCookiefIEfield
, Twebrequest.cookie, TwebRequest.cookiefields, TWebrequest.ExtractCookiefIEfields, etc., should be
Very convenient. But I want to set up cookies in order to achieve one function, but I found that the setCookIEfields provided using Delphi is not
Successfully, the HTTPAPP.PAS and ISAPIAPP.PAS files collided under the study of Delphi 3 discovery in Chinese Windows 95 and NT environments
wrong. According to NetScape
The format of the cookie should be: set-cookie: name = value; expires = data;
Path = path; domain = domain_name; Secure and according to regulations
Date (DATA) settings must meet the format "WDY
DD-MON-YYYY HH: MM: SS GMT "
Based on RFC822
RFC850
RFC1036 and RFC1123, etc., but check
FUNCTION TCOOKIE.GETHEADERVALUE: String in httpapp.pas ('"expires ="
DateFormat '"gmt;"'
Expires);
Where const DateFormat = 'DDD
DD MMM YYYY HH: MM: SS '
this
The format generated in the English environment is correct
But the results generated in Chinese are not
Because the weeks and months will follow Chinese table
Method: As will produce "November" Chinese strings in November, this in Netscape Navigator and Microsoft Internet Explorer
I can't identify it.
Since the error is that the original VCL does not consider the Chinese environment, the modified method is: 1. Modify the VCL source program.
Copy the DCU file after compiling
Bet to the lib directory, which will completely correct the error, which is the most fundamental solution, but if the source program is placed in another unmodified
Delphi (eg, providing source programs to others and reinstall themselves) compiling problems. 2, because there is not much purpose, so you can put the modified program in your own program, use the TWEBRESPONSE.SETCUSTOMHEADER settings provided by Delphi 3
This kind of benefit
It is entirely correct to place the program in its own procedure, reloading Delphi or compiling on another computer. Because of cookie
The purpose is generally two, one is used in this session process, and it is not used. At this time, there is no need for the expiRES segment, and there is no time error.
You can use all the cookie programs provided by Delphi 3; the other is permanently saved, the longer the time, so you can set the time setting.
February 22, 2099
So the method of setting the cookie in the program is
: Response.SetcustomHeader ('set-cookie "
'Name = value; expires = sun
22 Feb 2099 08:08:08
GMT '); (Note injects its own name, such as setting count = 10, then replace by count, Value uses 10 replacement),
You can build a cookie.
The following is a program for accessing a counter, you can refer to:
Const
Lastip: String = '0: 0: 0: 0'; // Avoid repeating count
VAR
String;
Count: integer;
Begin
S: = Request.cookiefIELDS.VALUES ['count'];
IF S <> '' Then Begin
Try
Count: = start (s);
Except
Count: = 0;
END;
ELSE COUNT: = 0;
if Lastip <> Request.RemoteAddr Then Inc (count);
Lastip: = Request.RemoteAddr;
Response.setCustomHeader ('set-cookie "
'count =' INTOSTR (count) ';
Expires = Sun
21 Feb 2010
08:08:08 GMT ');
Response.Content: = 'You are the' INTOSTR (count) 'coming to this page!';
END;
(The above program uses Win95B personal web server Netscape Navigator 4.04 debugging)