
Class CL_BSP_SERVER_SIDE_COOKIE
Overview
Class
CL_BSP_SERVER_SIDE_COOKIE provides methods for setting, getting, deleting, and managing cookies on the server.Server-side cookies are persistent data, similar to the usual client-side cookies. However, while on the client-side, there are restrictions that limit the size of cookies to around 4 kilobytes per cookie, the number of cookies to 300 in total and 20 per server or domain, server-side cookies are subject to no such restrictions. A server-side cookie is stored on the database.
For technical reasons, each individual cookie can be stored in one of the following ways:

When you get a cookie, please note that it must be returned to the same data structure. Otherwise, an error will occur, which you can query using an error method.
The parameters
username and session_id deserve special attention. Setting username to sy-user is ambiguous in cases where an application is started by an anonymous user stored on the server. It would be better to use session_id (see example) since runtime->session_id indicates the browser session.When you design an application, you should give careful consideration to whether the application should be stateless and the required context data be retained from page to page in cookies (client-side or server-side), or whether the application should be stateful. A stateful application makes sense when there is a large amount of context data that would otherwise have to be read from or written to the database using cookies and thus slow down performance (see also
Stateful or stateless programming?).The program
BSP_SHOW_SERVER_COOKIES provides an overview of all of the cookies set in the system. The program BSP_CLEAN_UP_SERVER_COOKIES deletes all expired cookies to the day.
The system administrator should schedule the program
Class
CL_BSP_SERVER_SIDE_COOKIE is contained in the package SBSP_RUNTIME.Inheritance Hierarchy/Interface Composition
Implemented Interface
-
Superclass
-
Attributes
|
Attribute Name |
Declaration Type |
Description |
|
CC_OK |
Constants |
Action was successful. |
|
CC_WRONG_DATA_OBJECT |
Constants |
The data object of the cookie to be read does not match the data object of the set cookie. |
|
CC_PARAMETER_MISSING |
Constants |
Call parameters are missing. |
|
CC_NOT_EXISTS |
Constants |
Cookie does not exist. |
Methods

All of the methods are in the visibility section public section.
Method get_server_cookie
|
Signature |
method GET_SERVER_COOKIE |
|
|
Description |
This method gets a server cookie. |
|
|
Parameters |
EXPIRY_TIME |
Validity date (time): to time |
|
EXPIRY_DATE |
Validity date (date): to date |
|
|
DATA_NAME |
Data object name |
|
|
SESSION_ID |
Session ID |
|
|
USERNAME |
Name of user |
|
|
APPLICATION_NAMESPACE |
Name space of BSP application |
|
|
APPLICATION_NAME |
Name of BSP application |
|
|
NAME |
Name of cookie |
|
|
DATA_VALUE |
Data object content |
|

data: sorders type sales_orders,
edate type d,
etime type t,
usr type string.
clear
sorders.call
method cl_bsp_server_side_cookie=>get_server_cookieMethod delete_server_cookie
|
Signature |
method DELETE_SERVER_COOKIE |
|
|
Description |
This method deletes a server cookie. |
|
|
Parameters |
NAME |
Name of cookie |
|
APPLICATION_NAME |
Name of BSP application |
|
|
APPLICATION_NAMESPACE |
Name space of BSP application |
|
|
USERNAME |
Name of user |
|
|
SESSION_ID |
Session ID |
|

data: usr type string.
call
method cl_bsp_server_side_cookie=>delete_server_cookieMethod set_server_cookie
|
Signature |
method SET_SERVER_COOKIE |
|
|
Description |
This method sets a server cookie. |
|
|
Parameters |
DATA_VALUE |
Data object content |
|
EXPIRY_DATE_ABS |
Valid to date |
|
|
EXPIRY_TIME_ABS |
Absolute validity duration
If you do not specify a value, the system sets the absolute validity duration to 23.59. |
|
|
DATA_NAME |
Data object name |
|
|
SESSION_ID |
Session ID if required |
|
|
USERNAME |
Name of user, and e-mail address |
|
|
EXPIRY_TIME_REL |
Relative validity duration in seconds
If you do not specify a value, the system sets the relative validity duration to 23.59. |
|
|
EXPIRY_DATE_REL |
Validity duration in days |
|
|
APPLICATION_NAMESPACE |
Name space of BSP application |
|
|
APPLICATION_NAME |
Name of BSP application |
|
|
NAME |
Name of cookie |
|

data: sorders type sales_orders,
call
function 'BAPI_SALESORDER_GETLIST' destination 'ABC'edate = sy-date.
add 1 to
edate. "valid for one daycall
method cl_bsp_server_side_cookie=>set_server_cookieMethod get_last_error
|
Signature |
method GET_LAST_ERROR |
|
|
Description |
This method returns the return code of the last call. |
|
|
Parameters |
RC |
Returncode |

data:
rc type i,rc = cl_bsp_server_side_cookie=>get_last_error( ).
Method get_last_error_name
|
Signature |
method GET_LAST_ERROR_NAME |
|
|
Description |
This method returns the internal name of the exception of the last call. |
|
|
Parameters |
NAME |
Internal error text |

data: rc type i,
rc =
cl_bsp_server_side_cookie=>get_last_error( ).if
rc ne 0.txt = cl_bsp_server_side_cookie=>get_last_error_name( ).
endif.
Method get_server_cookie_info
|
Signature |
method GET_SERVER_COOKIE_INFO |
|
|
Description |
This method returns information about server cookies. |
|
|
Parameters |
COOCIES |
List of all cookies. |
|
APPLICATION_NAMESPACE |
Name space of BSP application |
|
|
SESSION_ID |
Session ID |
|
|
USERNAME |
Name of user |
|
|
NAME |
Name of cookie |
|
|
APPLICATION_NAME |
Name of BSP application |
|

data: usr type string,
call
method cl_bsp_server_side_cookie=>get_server_cookie_info