• Post Reply Bookmark Topic Watch Topic
  • New Topic

Form Login Authenicaton-can I store that user has already logged in

 
Will Reilly
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers,
have been looking at using the Form Auth method for securing some of my pages and it looks good but I would like to be able store the fact that they have already logged. Then I would be able to check it when they try to access certail pages and grant acces if they already have. Is there something build into the API to do this?
Cheers in advance
Williery
 
Vikalp Setya
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
One way to do this is to store some flag in the session that specifies whether user has logged in or not. What i mean is that once the user logs in set that flag to true in session and in pages where you want to check whether user has logged in or not, just check whether that flag is set in session. If yes, show the contents else move to the login page.
if(loginSuccessful)
session.setAttribute("logged",new Boolean(true));
in pages that needs check, first do
Boolean logged = (Boolean) session.getAttribute("logged");
if(logged.booleanValue() == true)
{
//serve the contents
}
 
Will Reilly
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thats pretty much what I did in previous projects that where not in Java, thought that I would look into these build in methods but it looks like i would have to combine the two method which would make things too complicated. Will go for your method
Cheers
Williery
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!