Skip to main content

Can session persist accross browser session

1 reply [Last post]
sol1001
Offline
Joined: 2009-02-19

Is it possible to allow a session to persist a browser shutdown? I suspect the JSESSIONID cookie would need to be made a permanent instead of a session cookie but I haven't found a way to do that.

Specifically I'm trying to allow a logged in user to resume their session after their browser is shutdown and restarted.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Jan Luehe

On 11/28/09 09:39, glassfish@javadesktop.org wrote:
> Is it possible to allow a session to persist a browser shutdown? I suspect the JSESSIONID cookie would need to be made a permanent instead of a session cookie but I haven't found a way to do that.
>
> Specifically I'm trying to allow a logged in user to resume their session after their browser is shutdown and restarted.
>

Yes, this can be done using the new configuration capabilities for
session tracking cookies provided by Servlet 3.0 (and implemented
by GlassFish v3):

You can set the expiration of time of your application's session tracking
cookies declaratively, by specifying the max-age element in your
web.xml deployment descriptor, as follows:




...


or programmtically (e.g., from a ServletContextListener), as in the
following example:

public class ConfigListener implements ServletContextListener {

public void contextInitialized(ServletContextEvent sce) {
sce.getServletContext().getSessionCookieConfig().setMaxAge(...);
}

If you are using a pre-v3 GlassFish release, you can configure the
expiration of your application's session tracking cookies using the
(non-portable) sun-web.xml deployment descriptor, as follows:





Jan

> [Message sent by forum member 'sol1001' ]
>
> http://forums.java.net/jive/thread.jspa?messageID=373673
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: users-help@glassfish.dev.java.net
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net