Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Henry Wong
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Joe Ess
  • salvin francis

How to check if the user is logged in in JSF

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to know if the user is logged in, if not will be redirected to login page.

How can i do this?
 
Ranch Hand
Posts: 1585
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Store some token in the session object.

If that token (let's say isLoggedIn) is avaliable (which will be stored upon successful login), then the user is in.

Otherwise, do your normal redirection.

Regards,
 
Saloon Keeper
Posts: 21433
143
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, in most cases the mere existence of a session means you're logged in - depending on what you define as "logged in". However, to accurately test for a session, you should make sure that you call the get session method with the right option. Otherwise get session will create a session if one didn't already exist, so it would always say you were logged in, even if you hadn't authenticated or set up whatever session parameters your login process might initialize.
 
I promise I will be the best, most loyal friend ever! All for this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!