Show TOC

Accessing CookiesLocate this document in the navigation structure

Use

GET_COOKIE() and GET_COOKIES() are used to allow the HTTP request handler access to cookies sent with the HTTP request. All cookie names are case-insensitive. If necessary, you can use method SET_COOKIE.

Features

SET_COOKIE()

You use this method to define new cookies as HTTP servers.

The following section provides an overview of the parameters. These are always import parameters.

Parameters

Syntax

Description

NAME

NAME = <Name>

Name of cookie Mandatory parameter

VALUE

VALUE = <Value>

Value of cookie Mandatory parameter

PATH

PATH = <Path name>

Determines the path attribute for a specified cookie. If you do not specify a value as a pathname, the system uses the path of the page that the cookie generated.

DOMAIN

DOMAIN = <Domain name>

Determines the domain attribute for a specified cookie. If you do not specify a value as the domain name, the system uses the host name of the server that generated the cookie response.

EXPIRES

EXPIRES = <Wdy, DD-Mon-YY HH:MM:SS GMT>

Determines the timestamp (date and time) when the cookie lifetime ends. As soon as the cookie lifetime expires, it is no longer stored or returned.

The timestamp has the following format: Wdy, DD-Mon-YY HH:MM:SS GMT, such as Tue, 15 Nov 1994 12:45:26 GMT.

If you do not set a date, the cookie is stored as a session cookie, otherwise it is stored on the hard drive.

SECURE

SECURE = 1 / 0

The cookie is only transferred if the communication channel to the host is secure. Currently, only those servers that communicate via HTTPS (that is, HTTP with SSL) are secure. The default value 0 specifies an insecure connection. 1 indicates the connection is secure.

Example
                    


                    
data: cookie type string,
                    
expiry type string,
                    
ts type bsptimestamp,
                    
ttss(14) type c.
                    


                    
ts-date = sy-datum + 1.
                    
ts-time = sy-uzeit.
                    
ttss = ts.
                    
cookie = 'This is a test cookie'.
                    


                    
class cl_bsp_utility definition load.
                    
expiry = cl_bsp_utility=>date_to_string_http( timestamp = ttss ).
                    


                    
*set the new cookie
                    
call method response->set_cookie
                    
exporting name = 'testcookie'
                    
value = cookie
                    
expires = expiry.