Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Session Variables

 
Mathews P Srampikal
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how the server will know whether this session is belongs to usr1 or usr2 in the request......How the URL rewriting works with a session.
Thanks
 
Dave Vick
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mathews
Every time a session is created there is a unique session id created by the container and sent to the browser that originated the request that created the session. So if you have two users they would each get their own session id and then every time they request a resource from that application the container gets the session id from the cookie that is stored on the users computer.
URL rewriting is used for when cookies are disabled, it works by taking any URLs sent back to the client and appending the session id to it, that way the session id is part of any request sent by the browser to the container.
Does that help, if you need a more detailed explaination let me know.
 
Mathews P Srampikal
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Dave
 
varun bihani
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The more simple method I guess would be assign a unique ID for each user to the particular name and setting its session attribute like this..
session.setAttribute("userid",userid);
and then getAttribute like..
String userid=(String)session.getAttribute("userid");
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic