jump to navigation

Difference between session and cookie? February 7, 2007

Posted by Allu in J2EE.
trackback

1) session should work regardless of the settings on the client browser. even if users decide to forbid the cookie (through browser settings) session still works. there is no way to disable sessions from the client browser.
2) session and cookies differ in type and amount of information they are capable of storing.
Javax.servlet.http.Cookie class has a setValue() method that accepts Strings. javax.servlet.http.HttpSession has a setAttribute() method which takes a String to denote the name and java.lang.Object which means that HttpSession is capable of storing any java object. Cookie can only store String objects.

Advertisements

Comments»

1. shyam - March 9, 2007

cookies with disable , .get me information abt that

2. sam - August 14, 2007

Hi

3. karthick - September 13, 2007

cookies is small variable.name denotes cookies the small biscuit .this stored client computer

4. karthick - September 13, 2007

hai better you visit it information on
http://fresherscorner.com
orcookies

5. Maximus - December 20, 2007

I would like to see a continuation of the topic

6. music - January 7, 2008

very interesting.
i’m adding in RSS Reader

7. Amaresh Chandra Samal - December 5, 2008

A session is an object associated with a client connection to the server. it has the ability to carry information related to the client. since http is a connectionless protocol, developers need an ability to “remember” what the client of the application did during the visit to the page.EX: “shopping cart”
Cookies are the server side information stored in the client browser according to user settings. but if an user blocks that cookie then the actual user will be in trouble

8. PHPtrainee - September 2, 2009

Sessions will be destroyed if you close the browser.. sessions will be maintained till we quit the browser… (not save and quit)
sessions are the variables that stored in client browser.. and cookies are the information that are stored in client hard disk

Alagiri - September 14, 2009

If you set the variable to “cookies”, then your users will not have to log in each time they enter your community.

The cookie will stay in place within the user’s browser until it is deleted by the user.

But Sessions are popularly used, as the there is a chance of your cookies getting blocked if the user browser security setting is set high.

If you set the variable to “sessions”, then user activity will be tracked using browser sessions, and your users will have to log in each time they re-open their browser. Additionally, if you are using the “sessions” variable, you need to secure the “sessions” directory, either by placing it above the web root or by requesting that your web host make it a non-browsable directory.

The Key difference would be cookies are stored in your hard disk whereas a session aren’t stored in your hard disk. Sessions are basically like tokens, which are generated at authentication. A session is available as long as the browser is opened.

9. Faheem kalwar - December 27, 2009

Difference between Session and Cookie

What is the difference between session and cookie?

If you set the variable to “cookies”, then your users will not have to log in each time they enter your community.

The cookie will stay in place within the user’s browser until it is deleted by the user.

But Sessions are popularly used, as the there is a chance of your cookies getting blocked if the user browser security setting is set high.

If you set the variable to “sessions”, then user activity will be tracked using browser sessions, and your users will have to log in each time they re-open their browser. Additionally, if you are using the “sessions” variable, you need to secure the “sessions” directory, either by placing it above the web root or by requesting that your web host make it a non-browsable directory.

The Key difference would be cookies are stored in your hard disk whereas a session aren’t stored in your hard disk. Sessions are basically like tokens, which are generated at authentication. A session is available as long as the browser is opened.
Faheem kalwar

10. shankar kumar - May 27, 2011

Sessions are not reliant on the user allowing a cookie. They work instead like a token allowing access and passing information while the user has their browser open. The problem with sessions is that when you close your browser you also lose the session. So, if you had a site requiring a login, this couldn’t be saved as a session like it could as a cookie, and the user would be forced to re-login every time they visit.

11. guru - November 29, 2011

Sessions Sessions Sessions Sessions Sessions Sessions Sessions Sessions Sessions Sessions Sessions Sessions Sessions Sessions
Cookie Cookie Cookie Cookie Cookie Cookie Cookie Cookie Cookie Cookie Cookie Cookie Cookie Cookie Cookie Cookie Cookie Cookie


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: