I want to write a servlet with which I can create a new session.
The servlet requires the user to authenticate with BASIC authentication
and returns the standard session cookie (using HttpServletRequest#getSession(true)
). However, if the client uses the received session cookie in his next request instead of BASIC authentication
it is not authenticated. The server recognizes the session but it doesn't contain the user information.
I'm using Tomcat and after a bit of debugging the reason is also obvious: the user information (Principal) is added to session upon authentication. However when the first BASIC authentication is taking place no session exists yet as this will be created by the servlet. Does anyone have idea how to solve this problem?