//清空session
request.getSession().invalidate();
//获得新的session
session = request.getSession();
String randomString = UUID.randomUUID().toString();
session.setAttribute("_TOKEN",randomString);
//实现自动登录
String method = request.getParameter("method");
Cookie[] cookies = request.getCookies();
String userId = "";
String url = "";
boolean flag = false;
if (cookies != null && method == null)
{
for (int i = 0; i < cookies.length; i++)
{
Cookie cookie = cookies[i];
if ("userExist".equals(cookie.getName()))
{
userId = cookie.getValue();
session.setAttribute("cookieUser",userId);
flag = true;
break;
}
}
if(flag)
{
response.sendRedirect("LoginSubmit?_TOKEN=" + randomString);
return;
}
}
request.getSession().invalidate();
//获得新的session
session = request.getSession();
String randomString = UUID.randomUUID().toString();
session.setAttribute("_TOKEN",randomString);
//实现自动登录
String method = request.getParameter("method");
Cookie[] cookies = request.getCookies();
String userId = "";
String url = "";
boolean flag = false;
if (cookies != null && method == null)
{
for (int i = 0; i < cookies.length; i++)
{
Cookie cookie = cookies[i];
if ("userExist".equals(cookie.getName()))
{
userId = cookie.getValue();
session.setAttribute("cookieUser",userId);
flag = true;
break;
}
}
if(flag)
{
response.sendRedirect("LoginSubmit?_TOKEN=" + randomString);
return;
}
}