• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

cookies exist when we close browser?

 
Veena Pointi
Ranch Hand
Posts: 442
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does cookies exist when we close browser and open other one?How about session? As per my understanding, Container considers requests from 2 browsers as 2 different clients.It has no way of figuring out 2 browsers are n same machine or difft? so if you close browser and open the same request in new browser,to the container it is different request,so it creartes new session,new cookies....?

How can we make cookies to exist even when we close browser?

Thanks
Veena
[ March 07, 2006: Message edited by: Veena Point ]
 
Chandra Sagi
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can we make cookies to exist even when we close browser?


Cookies could be given a lifetime when we declare them. We could use cookie.setMaxAge(int) where is in seconds. when we set it to -1 the cookie disappears when we close the browser. A zero value causes the cookie to be deleted.

And about your question when the same cookie could be used by two browsers at same time from the same machine is YES. The cookies are stored in a particular location in your computer and with the name of the URL generally. When you open an URL it first looks whether there is any cookie associated with the particular URL and sends it with the request. You can even come after sometime and see that the cookie is still alive.

A browser is expected to support 20 cookies for each webserver, 300 cookies total and may limit the size to 4kb each.

Hope this helps.

Thanks
Chandu
 
Veena Pointi
Ranch Hand
Posts: 442
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for replieng.By default what value of max age is set for cookie.And was curious what location we can look into on our hard disk to see cookies and their values?
 
Chandra Sagi
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not sure about the default value. I guess it would be -1, to delete the cookie as soon as we exit out of the browser. As I told you before we can use the same cookie from two browsers, so is the reason when you signout of any credit card website they ask you to close all your browsers to the site for security. By doing so you would invalidate all the cookies from the website.

You could find cookies in your cookie folder in C:\Documents and Settings\"your computer name"\cookies

Thanks
Chandu
 
Narendra Dhande
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Container considers requests from 2 browsers as 2 different clients.It has no way of figuring out 2 browsers are n same machine or difft?


It is not true. It is absoultely brower dependent. Try it on IE, it treate 2 open windows differently. But in case of Firefox it treat as session from one breower for two windows.

Thanks
 
Veena Pointi
Ranch Hand
Posts: 442
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Narendra Dhande:
Hi,



It is not true. It is absoultely brower dependent. Try it on IE, it treate 2 open windows differently. But in case of Firefox it treat as session from one breower for two windows.

Thanks


But theoratically Container can not differentiate 2 browser requests ,right.May be cookies are not enabled in IE and are enabled in FireFox?
 
Celinio Fernandes
Ranch Hand
Posts: 549
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, you need to know that there are 2 kind of cookies :
session cookies and permanent cookies

http://java.sun.com/j2se/1.5.0/docs/guide/deployment/deployment-guide/cookie_support.html

Session cookie :
a cookie that is erased when the user closes the Web browser.

Permanent cookie :
a cookie that is stored on a user�s hard drive until it expires or until the user deletes the cookie
 
Veena Pointi
Ranch Hand
Posts: 442
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This clears everything.Thanks Max.
 
Chandra Sagi
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Narendra,

It is not true. It is absoultely brower dependent. Try it on IE, it treate 2 open windows differently. But in case of Firefox it treat as session from one breower for two windows.


I came across accessing a session from two windows of IE and it says

What constitutes a �new browser session�? Here�s an observation on Internet
Explorer�s behavior. If you launch Internet Explorer afresh, then access a session-
aware servlet�that�s a new session. If Internet Explorer itself launches a
new Internet Explorer window (e.g., by running File | New Window or by running
some appropriate script) and that new window accesses a session-aware
servlet�it shares the session object with the Internet Explorer window from
which it was launched. This makes reasonable sense, and it�s probably not the
only browser that exhibits this behavior.


Source: SCWCD Study guide - Osborne

It might be browser dependent also.

Thanks
Chandu
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic