RPGspCookie Function


Saves a cookie to the end-user's computer. Does not return a value.


Syntax

RPGspCookie(name : value : domain : path [: secure flag] [: expiration])

Part Description
name Required. The name of the cookie.
value Required. Character expression representing the value to save in the cookie.
domain Required. Domain name (e.g. 'profoundlogic.com') the cookie is assigned to. You can specify an empty string (e.g. '') to indicate that the host name of the page generating the cookie request should be used.
path Required. The path (e.g. '/rpgsp/') the cookie is assigned to. Leave blank for none.
secure flag

Optional. Indicator to specify whether the cookie is secure. Valid values are *ON ('1') or *OFF ('0'). If *ON, the cookie will be returned only under SSL (Secure Sockets Layer).

expiration

Optional. Timestamp parameter to specify when the cookie will expire.


Remarks

Cookies are used to save information on the end-user's computer. Typically, they are used to store information so that the site can identify the user between visits. For example, a cookie can store the user's personal preferences. A cookie also stores a description of the range of URLs (domain + path) for which the cookie is valid. Any future HTTP requests, which fall in that range, will include a transmittal of the current value of the cookie.

The value passed to RPGspCookie is not actually saved until the page has executed entirely and is sent to the client. This cookie value can be retrieved later by its cookie name with the RPGspIn function.

To remove a cookie, use the RPGspCookie function to send a cookie with an expiration date and time that is in the past.


Examples

The following code saves a cookie, which is set to expire in 10 days:

     D  Exp            S               Z   Inz(*SYS)
 
     C                   AddDur    10:*DAYS      Exp
 
     C                   CallP     RPGspCookie('VisitorId' : %Char(VID) :
     C                               '' : '/rpgsp/' : *Off : Exp)


The following removes a cookie:

     D  Exp            S               Z   Inz(*SYS)
 
     C                   SubDur    2:*DAYS       Exp
 
     C                   CallP     RPGspCookie('VisitorId' : %Char(VID) :
     C                               '' : '/rpgsp/' : *Off : Exp)

Note the use of %Char to convert a numeric value to characters before passing to RPGspCookie.


See Also

RPGspIn

RPGspSave

%Char


Profound Logic Software, Inc.
www.ProfoundLogic.com
(937) 439-7925