newman     VBWeb     VBSource     Portfolio    
OUT ON THE INTERNET


Home

Getting Started
- Hello World Example
- SampleMain Example
- Code Snippets
- Request Collection
- Missing Terms
- Multi-Select
- Names Collection

User Guide
- Debugging
- Stepping Through Code
- HTML Templates
- Cookies

Command Reference
- AddToRequest
- BackupRequest
- CgiDebugPrint
- ErrorHandler
- Escape
- Extract
- FileContents
- FileExists
- GetRequest
- GmtDate
- IsVBIDE
- LoadRequest
- Parse
- Redirect
- Replace
- Send
- SendLn
- ServerVariables
- SetCookie
- StandardIn
- UrlDecode
- UrlEncode

Appendix
- Web Server Directory Mapping
- Computer Name & IP Address

Reference - SetCookie
Returns the header text needed to set a cookie.
Syntax()
TextOut = SetCookie(Name, Value[, Expires[, GmtOffset[, Domain[, Path[, Secure]]]]])
Part
Description
Name Required text that is the Name in the Name/Value pair of the cookie. This gets URL encoded so that it can contain special characters.
Value Required text that is the Value in the Name/Value pair of the cookie. This gets URL encoded so that it can contain special characters.
Expires Optional date and time (in VB format) in the local time zone that defines the life time of the cookie. When the expiration date is reached, the cookie gets deleted. If you do not specify Expires, the cookie expires when the visitor closes the browser. If you use a date earlier than now, the cookie expires instantly.
GmtOffset Optional number of hours between the local time zone and Greenwich Mean Time. Negative (-) is for the US and positive (+) is for Japan. Eastern US is -5.
Domain Optional text that specifies the domain attributes for a valid cookie. If you do not specify a value for Domain, Navigator uses the host name of the server which generated the cookie response.
Path Optional text that specifies the path attributes for a valid cookie. If you do not specify Path, the browser uses the path of the CGI script.
Secure Optional boolean value that specifies that the cookie is transmitted only if the communications channel with the host is secure. Only HTTPS (HTTP over SSL) servers are secure. If SECURE is not specified, the cookie is considered sent over any channel.
Remarks
Cookie headers must be sent in the Header section of the response page as demonstrated by the examples below. Each Header must be in its own line. SetCookie puts vbCrLf at the end of the cookie header for you. The first blank line (two 'vbCrLf's in a row) separates the Header section of the response page from the HTML. You can send several cookie header lines in the header section. Every cookie you set comes back to you in the Request collection. A cookie header has many optional parameters, all of which are also optional in this command. To remove a cookie, send another cookie with the same name so that it replaces the existing cookie. But this time, send it with an old expiration date.

Examples
This cookie sets Color=Red and expires in 12 hours from a server in NYC (Offset=-5). Send CGI_CONTENT_TYPE_TEXT_HTML Send SetCookie("Color", "Red", Now+12, -5, , "/") Send vbCrLf Send "<HTML>Hi there!</HTML>" Cookies are frequently used as a key to a Session table. In this case, the cookie should expire when the visitor closes the browser. Of course, you don't want to set SessionId if the visitor already has one. Send CGI_CONTENT_TYPE_TEXT_HTML If GetRequest("SessionId") = "" Then Send SetCookie("SessionId", NextId()) End If Send vbCrLf Send "<HTML>Hi there!</HTML>"


Copyright 1997 NEWMAN Services Corp. All rights reserved.
973-228-5753 pres@newmanservices.com