java - check on certain page if any user is logged in or not in jsp -
i have main page in which, if user logged in, visit next page.if not, directed login page , after user login, directed right left.
for scenario can use spring security (tutorial) check have access page or not if not first login page display after login can redirect next page. spring provide default login page. can manually using preserving login state of user.
for manually checking login status:
suppose have 4 pages
1)login page:
check users credentials , after login store session id user database , return user next request
2)page 2
fetche previous session id , check user session id, if matched show next page else show login page
3)page 3
4)page 4
code accessing session
httpsession session = request.getsession(false); int sessionid = (int) session.getattribute("sessionid");
Comments
Post a Comment