Forums Register Login

Question on sessions and cookies

+Pie Number of slices to send: Send
Hi
Can anyone tell me on what would happen to the session object when
they have these following settings

1) session.setMaxInactiveInterval(-1)

2) <session-config>
<session-timeout>0</session-timeout>
</session-config>

3) <session-config>
<session-timeout>-1</session-timeout>
<session-config>

4)What is the value to be used for setMaxAge() on the cookie object
so that it can stay on the client forever ?

5) Though not related to sessions/cookies..I have read in some places
that the order of the elements appearing in DD has significance

What is this order and what would happen if those elements are not
specified in that order ?
+Pie Number of slices to send: Send
About 1,2,3,4 you can search yourself in the API and spec. It's a good exercice.
Concerning 5, it mays influence a few things. For example, the servlets with a <load-at-startup> set the the same number will be loaded in the order they have been defined in web.xml. (But I think it depends on the container)
The way listeners and filters are loaded is also related to the order.
+Pie Number of slices to send: Send
Thanks Satou ,
But my doubt on the cookies question still stands.
In the spec , for the setMaxAge(int expiry) function , it is specified
that
0 - cookie is deleted
<0 - cookie not persisted
>0 - cookie stays for so many seconds on the client.

But is it possible for the cookie to stay forever(i.e. remain active forever) on the client ?? If so what is the value to be specified ?

{There is a instance in HFSJ where it is mentioned that cookies can be
made to stay active forever on the client )
+Pie Number of slices to send: Send
I don't know about staying forever, but setMaxAge takes an integer, which should be enough to make it persistent for many years

If you want to keep some information forever, I think you should use something different. Like a DB.
[ January 26, 2006: Message edited by: Satou kurinosuke ]
+Pie Number of slices to send: Send
 


If you want to keep some information forever, I think you should use something different. Like a DB.



I didn't get you here. He is looking for storing the information on the client(browser) for ever and sending them back to the server with each request. In what way DB pictures here.
+Pie Number of slices to send: Send
Dear muthu kumaran,

1)Session will Never expire.
2)Session expires as soon as created, practically session can not be created.
3) Session will Never expire.
4) Anything < 0, it will make your cookie never to destroy.
5) IF you change the order of Listners, filters, Servlets: it affects the Order of Instantiation, or Call.BUT
IF you at random shuffle any element with some different element, say error-page put before servlet element, your app. Sever will complain at startup, that the file is wrong, as its checked against DTD.
I think that answers you.
Do reply back,
Mayank
+Pie Number of slices to send: Send
Hi Mayank,
Thanks for u'r answers.
For the 4th question on cookies," Anything < 0, it will make your cookie never to destroy" is not true coz the spec says if the setMaxAge() has a negative value, then the cookie will not be persisted and would be deleted
when the browser exits !!
+Pie Number of slices to send: Send
Hi Mayank,

Also answer (3) is not correct.

If the <session-timeout> is set to "0" or "-1" in the DD, the session will never expire.

In the case of a servlet, setMaxInactiveInterval has to be set to "-1" only in order for the session to not expire. Setting it to "0" will expire the session immediately.

The DD and servlet are not consistent when it comes to setting the timeout of the session.

I learned this by answering one of the coffee cram exams in HFSJ.
You’ll find me in my office. I’ll probably be drinking. And reading this tiny ad.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 870 times.
Similar Threads
how to disable session time out
Not able to get this !
http session timeout
session timeout in DD
Resin session help
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 07:02:19.