Show TOC

Function documentationAccessing Cookies Locate this document in the navigation structure

 

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

Syntax Syntax

  1. data: cookie    type string,
  2.       expiry    type string,
  3.       ts        type bsptimestamp,
  4.       ttss(14)  type c.
  5. ts-date  = sy-datum + 1.
  6. ts-time  = sy-uzeit.
  7. ttss     = ts.
  8. cookie   = 'This is a test cookie'.
  9. class cl_bsp_utility definition load.
  10. expiry = cl_bsp_utility=>date_to_string_http( timestamp = ttss ).
  11. *set the new cookie
  12. call method response->set_cookie
  13.     exporting name    = 'testcookie'
  14.                value  = cookie
  15.               expires = expiry.
End of the code.