This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes Difference between Cookies and Session Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Difference between Cookies and Session" Watch "Difference between Cookies and Session" New topic
Author

Difference between Cookies and Session

Mahendran Aiyappan
Ranch Hand

Joined: Sep 05, 2005
Posts: 102
Can anybody say the difference between Cookies and Session

Thanks
Pavel Kubal
Ranch Hand

Joined: Mar 13, 2004
Posts: 356
Check this out, I hope this helps you.

http://www.theserverside.com/discussions/thread.tss?thread_id=3436
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1

Cookies are placed on the client machine. Cookies contain String name/value pairs. They can be turned off by a client, or a client can reject them, so they are a somewhat unreliable way of placing information on a client machine.

A session, or HttpSession, is part of the Servlet API, and helps to turn a stateless protocol, like HTTP, into a stateful protocol.

Here's more information than you ever wanted to know about the HttpSession.

http://www.technicalfacilitation.com/get.php?link=sessions

"The HttpSession adds state to a stateless, web based, interaction with a server. When a client makes a call to an application server, a Servlet developer can programmatically create and associate an HttpSession with that client. The session can then be used to keep track of all sorts of information about the user.

If the user tells us their favorite color, we can store that information in their session. If the user gives us their address and phone number, we can store that in their session. If they�re taking an online exam, we can put the answer to every question they�ve been given into the session as well. We can then go back into that session object, at any point in time, and pull that information out.

So when a user is done taking an online exam, we can go into their session and find out which questions they got correct, and which questions they got wrong. If the client is picking out books, or other products they want to purchase, when they click �check out,� we can go into their session, process their order, and tell them how much their purchase will be.

HttpSessions add state to a stateless protocol, and they are pivotal in making online applications work."

Cheers!
 
jQuery in Action, 2nd edition
 
subject: Difference between Cookies and Session
 
Similar Threads
web-inf vs meta-inf
Session Facade vs Session Bean
Difference between HTTPSession & Cookies
Session Facade vs Session Bean
declare cookies in jsp