luni, 13 aprilie 2015

[OmniFaces utilities (2.0)] Get the unique identifier assigned to this session (session ID)


[OmniFaces utilities] The getSessionId() method returns a string containing the unique identifier assigned to this session. The identifier is assigned by the servlet container and is implementation dependent.

Method:
Usage:

Returns the unique identifier assigned to this session:

import org.omnifaces.util.Faces;
...
// e.g. XY4i-kp_0NIDotbQaugGaM3P
String sessionId = Faces.getSessionId();

This is the unique identifier that is returned usually stored on client as a cookie with name JSESSIONID, and can be also collected via Faces#getRequestCookie():

import org.omnifaces.util.Faces;
...
// e.g. XY4i-kp_0NIDotbQaugGaM3P
String sessionId = Faces.getRequestCookie("JSESSIONID");

Niciun comentariu:

Trimiteți un comentariu