Reputation: 8626
I want to generate unique session id for my session. So i used UUID. Here what i did
if (session == null) {
session = httpServletRequest.getSession(true);
session.setAttribute("logedin", "0");
if (!httpServletRequest.isRequestedSessionIdFromCookie()) {
UUID sessionID = UUID.randomUUID();
Cookie sessionCookie = new Cookie("JSESSIONID", "sessionID"); //problem
}
The Cookie constructor accept two strings, how can i convert my UUID to string so it get the UUID value which is unique? Thanks
Upvotes: 21
Views: 90813
Reputation: 9476
This will convert your uniques session id to string
String suuid = UUID.randomUUID().toString();
Upvotes: 50