I have been learning about sessions . To practice what I have learned I just created a "Number guess" game.
For that game I created three pages
First page is just a static page named index.html which just asks the user name
Second page prompts the maximum number limit to generate a random number between 0 to that number
Third page allows the user to enter the number to guess for randomly picked number
In that game I used user's name as session attribute. Using that attribute if the user enters his name again(user who is not at all finished his game) I just want to display the third page(guessing the number) without again asking the maximum number limit (second page).
It worked fine but it also happens the new user (which is not supposed to do )
So I want to create a NEW SESSION if user is the new one (by checking with existing user name session attribute).
If I used request.getSession(); It just returns the existing session .
Is it possible to create a new session forcefully even if there is an existing session ?
Thanks for all replies which helped me to get the concept well.
Actually I don't want to invalidate the session until the user wins the game or intentionally quits the game . That's why in the mean time if
some other user (different user name) sign in I need to keep tracks his records as well as those who didn't win the game till now
Information which I stored as session attribute are follows:
1.His name(which I'm using it great him)
2.Random number picked for him (only once )
3.Maximum limit number
From your replies I understood that only one jsessionid cookie will be available for a browser.
So I changed the game like this :
Once the user log in means another user can't log in (I just redirect to the 3rd page when someone request for first page)until the user quits or win the game(like how GMail works)
Now I feel good and can go ahead to learn further.
Once again thanks for all your replies which really helped me to understand the concept .
subject: Can we create more than one session in a Client ?