In a cookie session state management system, the client application or web browser provides the session ID in an HTTP cookie header instead of a URL. Cookie session management is supported with the 'Set-Cookie' HTTP response header of the sa_set_http_header system procedure.
The following example illustrates unique session ID creation within an HTTP web server SQL function where session IDs can be provided by a URL or a cookie:
CREATE FUNCTION set_session_cookie() RETURNS LONG VARCHAR BEGIN DECLARE session_id LONG VARCHAR; DECLARE tm TIMESTAMP; SET tm = NOW(*); SET session_id = 'session_' || CONVERT( VARCHAR, SECONDS(tm) * 1000 + DATEPART( MILLISECOND, tm ) ); CALL sa_set_http_option( 'SessionID', session_id ); CALL sa_set_http_header( 'Set-Cookie', 'sessionid=' || session_id || ';' || 'max-age=60;' || 'path=/session;' ); SELECT CONNECTION_PROPERTY( 'SessionID' ) INTO session_id; RETURN( session_id ); END;