数据存放在cookies
public static final String DEFAULT_SESSION_ID_KEY = "SESSION_ID_KEY"; @Override public String setSessionIDCookie(HttpServletRequest request, String userid, HttpServletResponse response) throws OAuthSystemException { String sessionid = CodeUtil.encodeByMD5(valueGenerator.generateValue() + userid); Cookie cookie = new Cookie(DEFAULT_SESSION_ID_KEY, sessionid); cookie.setPath("/"); // 表示关闭浏览器cookie过期 response.addCookie(cookie); return sessionid; } @Override public String getSessionIDCookie(HttpServletRequest request) throws OAuthSystemException { // TODO Auto-generated method stub Cookie[] cookies = request.getCookies(); if (cookies != null && cookies.length > 0) { for (Cookie c : cookies) { if (c.getName().equals(DEFAULT_SESSION_ID_KEY)) { return c.getValue(); } } } return null; } @Override public void delSessionIDCookie(HttpServletRequest request, HttpServletResponse response) throws OAuthSystemException { Cookie cookie = new Cookie(DEFAULT_SESSION_ID_KEY, ""); cookie.setMaxAge(0); response.addCookie(cookie); }
相关推荐
yangkang 2020-11-09
lbyd0 2020-11-17
sushuanglei 2020-11-12
85477104 2020-11-17
KANSYOUKYOU 2020-11-16
wushengyong 2020-10-28
lizhengjava 2020-11-13
星月情缘 2020-11-13
huangxiaoyun00 2020-11-13
luyong0 2020-11-08
腾讯soso团队 2020-11-06
Apsaravod 2020-11-05
PeterChangyb 2020-11-05
gaobudong 2020-11-04
wwwjun 2020-11-02
gyunwh 2020-11-02
EchoYY 2020-10-31
dingyahui 2020-10-30