How to convert a UUID value to a string

I want to create a unique session identifier for my session. Therefore, I used the UUID. Here is 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 accepts two strings, how can I convert my UUID to a string to get a unique UUID value? Thanks

+6
source share
3 answers

This will convert your uniques session id to string

 String suuid = UUID.randomUUID().toString(); 
+24
source

sessionID.toString ()?

msg2shortsoI'llinsertalinktotheapi: http://docs.oracle.com/javase/1.5.0/docs/api/java/util/UUID.html

0
source

You can call toString() for all Java objects ...

0
source

Source: https://habr.com/ru/post/913131/


All Articles