Session operation interface

Session operation interface


1. The sessionId of the Session is transmitted between the client and the server through the cookie of JSESSIONID.
2. The server will get the sessionId through the cookie JSESSIONID, and construct an HttpSession and put it in the request.
So we can get HttpSession from request.


Session operation interface:
HttpSession session = request.getSession();    //取得Session
String sessionId=request.getSession().getId();    //取得sessionId
session.setAttribute("variable name", value object); //Add attribute
session.getAttribute("variable name"); //Object is taken out at this time, generally need to be forced
session.removeAttribute("variable name"); //Remove attribute
session.invalidate(); //Delete all keys saved in session

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326981843&siteId=291194637