How can we know that a session already existed or just created?

There is a method isNew() inside the HttpSession object, whose return type is Boolean. It returns true if the session is just created.
HttpSession session=request.getSession();
If(session.isNew()){
Out.println(“this is new session”);}
Else{out.println(“welcome back”);}

No comments:

Post a Comment