Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 10.0.1 » SQL Anywhere Server - Programming » SQL Anywhere Web Services » Using HTTP sessions

Using HTTP sessions Next Page

Creating an HTTP session

A session is created within a web application using the HTTP option SessionID by calling the sa_set_http_option system procedure. A session ID can be any non-null string. Internally, a session key composed of the session ID and database name is generated so that the session key is unique across databases in the event that multiple databases are loaded. The entire session key is limited to 128 characters in length. In this example, a unique session ID is generated and passed to sa_set_http_option.

DECLARE session_id VARCHAR(64);
SET tm=now(*);
SET session_id = 'session_' || 
    CONVERT( VARCHAR, SECONDS(tm)*1000+DATEPART(millisecond,tm));
CALL sa_set_http_option('SessionID', session_id);

A web application can obtain the session ID through the SessionID connection property. This property is an empty string if no session ID is defined for the connection (that is, the connection is sessionless).

DECLARE session_id VARCHAR(64);

Once the session is created with the sa_set_http_option procedure, a localhost client can access the session with the specified session ID (for example, session_63315422814117) running within the database dbname running the service session_service with the following URL.


If only one database is connected, then the database name can be omitted.