Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using sessions for authentication

 
Jahar Heard
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to ask you something, how to use this session, when I log in , and then refresh the page it's back to the login form, I thing I'm doing something wrong.



 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the relationship between the session and whether or not the login page is shown? The code excerpt you posted doesn't show that.
 
Jahar Heard
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Here is my login form.

The code is "working".But when I log in, and when it display my name, when I refresh the page, login form appear, and the name disappear.I think my problem is whit the session .

Any Ideas ?
 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There should be some logic in the doGet method that checks whether a session exists, and -if there is one- does something other than display the login form - maybe redirect to the main page.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64629
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rather than checking for a session, check for the existence of something in the session. Much less fragile.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic