@ApiOperation(value = "用户退出登录", notes = "用户退出登录", httpMethod = "POST")
@PostMapping("/logout")
public IMOOCJSONResult logout(@RequestParam String userId,
HttpServletRequest request,
HttpServletResponse response) {
// 清除用户的相关信息的cookie
CookieUtils.deleteCookie(request, response, "user");
// TODO 用户退出登录,需要清空购物车
// TODO 分布式会话中需要清除用户数据
return IMOOCJSONResult.ok();
}
/**
*
* @Description: 删除Cookie带cookie域名
* @param request
* @param response
* @param cookieName
*/
public static void deleteCookie(HttpServletRequest request, HttpServletResponse response,
String cookieName) {
doSetCookie(request, response, cookieName, null, -1, false);
// doSetCookie(request, response, cookieName, "", -1, false);
}