e hënë, 18 qershor 2007

How to manage session in an application.

1) Cookie
- they store user information on local machine.
- this cookie is passed to browser for checking user authentication.
- some of the browsers does not provide support for cookies.

2) URL rewriting
- additional user information will be appended to the URL to pass information to the destination
- Cons - limitation is 256 chars of URL
- Cons - user data is exposed to the world

3) Hidden Variables in HTML/JSP
- user data is maintained across the HTML/JSPs using hidden fields
- and in servlets by using request.getParameter("") - by passing parameter names.

3) HttpSession class
- maintaining a session object across an active session.
- we can store diff. user objects, need to be maintained across the session.
- its a hashmap
- request.getSession(true), to get a new session if does not exist.
- overcomes limitations of cookie and URL rewriting for storing sessionID.
- set maximum lifetime of the session.

Nuk ka komente: