Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Servlets and HttpSessions

Very basic question. I have a portal containing several servlets, one of which takes care of logging in (but only as an admin). How do I use HttpSessions between Servlets to know if the admin is signed in?

Thanks in advance!

like image 843
whirlwin Avatar asked Feb 11 '26 20:02

whirlwin


2 Answers

Whenever your admin users signs in put something like session.setAttribute("admin","true");

check this as session.getAttribute("admin") to see if admin is logged in

like image 136
sushil bharwani Avatar answered Feb 13 '26 09:02

sushil bharwani


set an attribute in session

session.setAttribute("isAdmin",true OR false);

At the login time decide the user type and set it.

like image 29
jmj Avatar answered Feb 13 '26 08:02

jmj



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!