Session tracking in J2EE
In java we can do session tracking in the following way.
.....................................................................
1)Cookies
2)Hidden Form Field
3)URL Rewriting
4)HttpSession
.....................................................................
1)Cookies
2)Hidden Form Field
3)URL Rewriting
4)HttpSession
Cookies
==================================
There are 2 types of cookies in java servlets.
1) Non-persistent cookie
2) Persistent cookie
Non-persistent cookie
--------------------------------
It is valid for single session only. It is removed each time when user closes the browser.
Persistent cookie
---------------------------------
It is valid for multiple session . It is not removed each time when user closes the
browser. It is removed only if user logout or signout.
Cookies
----------------------------------------
creating the cookies
....................................
Cookie ck=new Cookie("user","sandeep_mishra"); //creating cookie object
response.addCookie(ck); //adding cookie in the response
deleting a cookie
....................................
Cookie ck=new Cookie("user",""); --deleting the cookie
ck.setMaxAge(0); //change the max age to 0
response.addCookie(ck);
deleting a cookie
....................................
Cookie ck=new Cookie("user",""); --deleting the cookie
ck.setMaxAge(0); //change the max age to 0
response.addCookie(ck);
Comments
Post a Comment