Q:I want to add a cookie to an actionitem, and then sendredirect to another actionitem to verify the cookie. If there is a cookie, a page is displayed; otherwise, a response is returned. However, after adding a cookie, if sendredirect is enabled, the other actionitem cannot obtain the cookie value (indicating that the cookie is not successfully added). If not, sendredirect is response. content: = 'content of a certain page'. Then, you can click link to another actionitem to read the cookie.
A:Cookie is the header of a response and must be set before the body. If sendredirect is used, only the new page will be sent. The response set before sendredirect will be canceled. As a result, the cookie cannot be added to the header of the new page. Therefore, the cookie setting is unsuccessful! Solution: Never use sendredirect after setting the cookie. The problem you mentioned can be solved as follows: You can add code in HTML to automatically go to another page. We can write in the onaction event of webactionitem:
Response. Content: = '<meta HTTP-EQUIV = "refresh" content = "1;' +
'Url = http: // Chen/dll/chat/chatmain.exe/qtchat "> '+
'<P> </P> <p align = "center"> your reply has been added to the Forum' +
'<Br> two seconds later, return to the Forum homepage </P> ';
The URL is automatically returned.
Q:I first set a value in the cookie and then want to modify it. What should I do?
A:First, delete the value in the original cookie by setting the Cookie's expires to the earlier time and then setting it. For example:
// Delete the records in the original cookie
With response. Cookies. Add do begin
Name: = 'nickname ';
Value: = request. contentfields. Values ['nickname'];
Secure: = false;
Expires: = now-1;
End;
// Use the registered user name as the content in the cookie
With response. Cookies. Add do begin
Name: = 'nickname ';
Value: = request. contentfields. Values ['nickname'];
Secure: = false;
Expires: = now + 100;
End;
Q:How do I save temporary information through cookies? Like some forums, during a single browsing process. When you speak for the first time, you need to enter the password. When you browse again, you still need to enter the password, which is convenient and secure.
A:To set such a cookie, do not set expires. For example:
// Set temporary cookies
With response. Cookies. Add do begin
Name: = 'temppassword ';
Value: = spassword;
End;
In addition, we can also download some special controls for setting and reading cookies. These controls support adding ASP-like session functions to Web applications. Yes: http://codecentral.borland.com/
Www.applevb.com