App Engine session cookie expiration - java

I'm developing an Java App Engine project with multiple modules. I have enabled the sessions in the appengine-web.xml for the default module:
<sessions-enabled>true</sessions-enabled>
When i open the default module in the browser; a session is created:
Upon closing the browser. The session is gone. When inspecting the cookies in the browser I only see 1 cookie for the domain:
JSESSIONION-c73210e91f2dc1e586e87edd793da6dc
with an expiration set to the end of the session. In the datastore there are entities created of the kind _ah_SESSION (I also see them in the memcache). So App Engine has enabled the sessions but is not giving me a persisting cookie with a default expiration of +30 minutes.
Is there something I am overseeing here ?
Update:
I have set the session timeout parameter in the web.xml just to be sure. But still no persisting cookie:
<session-config>
<session-timeout>100</session-timeout>
</session-config>

Related

set session cookie secure and httpOnly for LFR_SESSION_STATE_%

Environment :
Liferay 6.2 with Jboss
We are trying to implement httponly and secure.
For this we have dome some changes like below
Added in Portal-ext.properties :
cookie.http.only.names.excludes=
and
Added following properties in ROOT.war/WEB-INF/web.xml
<session-config>
<cookie-config>
<http-only>true</http-only>
<secure>true</secure>
</cookie-config>
</session-config>
I can see all the session cookies are httponly except the one which are starting with LFR_SESSION_STATE_
Can anyone suggest how we can handle this.
LFR_SESSION_STATE_ are cookies that explicitly get handled on client-side and not on server side - thus they're inherently only accessed through JS. As far as I know they're never even persisted on server side. And I don't expect any real leakage from these cookies. In my perception the cookies are about determining state of the quality "should this help item be shown with full text or just collapsed".

Redirecting to login when session timeout in JSF/Spring or automatic logout when session deactivate(or idel for a given time)

I have a J2EE application which uses JSF and Spring 3.x. My web app is developed in *.xhtml, and I have used JSF ManagedBeans.
I want to redirect to login page when the session has elapsed the timeoout. I am bit new and need to know the following.
How to set the session timeout time(Basically I want to set a maximum time where the application would be idle and redirect to the login page with an invalid session)
What is the meta tag which I need to place in my *.xhtml which will direct to the login page?
Hope the requirement is clear. Just stating the requirements of my problem again
System should not invalid the session as far as the user is interacting with the system.
It Should only invalid the session and redirect to the login page when the system has been idle for a given time.
Tech Stack
JSF with ManagedBeans(Have used face-config.xml etc..)
Spring for the service layer
Hibernate for the DAO layer and in defining the entities.
If by "idle" you mean not sending any request to the server then you have to set the session-timeout in your web.xml file. It should look like this for a 30 minutes timeout :
<session-config>
<session-timeout>30</session-timeout>
</session-config>
To handle the redirection to login when the session timeout have a look at this answer.

How frequent does Tomcat rotate JSESSIONID within same session

I was trying to scan a Webapp hosted in Tomcat and faced some difficulty and later realized even within the same session for an user tomcat changes JSESSIONID (monitored using Fiddler). I could not find any configuration in server.xml as such. Any info on this would be helpful
I would assume Tomcat would do this to defend Session Fixation
I believe default session timeout for Servlet, is 30 minutes.
Can be altered with <session-timeout> in web.xml.

Java EE / Struts persistent sessions

I'm doing my first Java EE web application and I'm struggling with sessions.
in my web.xml file I put the following settings:
<session-config>
<session-timeout>30</session-timeout>
</session-config>
But if I close my browser which is not configured to delete cookies on close,
after reopen the session is over.
How can I have a "persistent" session ?
check if a cookie named Jsessionid is getting created during your first request. And close your browser open it again and check if that cookie is still there and value is same.
I think it will not be, and that is the reason your session expires.
When a cookie's expiration is set to "session", it will get deleted by the browser when the user closes the browser. This has nothinng to do with the web.xml session-timeout setting, which will force-close the Java EE session server-side if there are no requests by the user in the designated timespan.
Spring has "remember me" functionality:
http://static.springsource.org/spring-security/site/docs/3.0.x/reference/remember-me.html

What is empty session path in tomcat?

I have read apache tomcat documentation a day before, and I am so confused about emptySessionPath . Up to my knowledge, if it's set to true, the emptySessionPath is stored at the root folder of web application. Please give the right definition of the term emptySessionPath and what happens if it is set to true and false?
Please guide me.Thanks in advance.
The emptySessionPath field just states whether the all cookie should be stored in the root URL path / (if emptySessionPath=true) or not (otherwise).
This is used by Apache's Connector. See details here (This is for AJP Connector, which is part of the Connnector object).
What this basically means is:
If emptySessionPath is enabled in
tomcat, the JSESSIONID cookie is
written to the root "/" path. This
means that whatever webapp you are on
will use the same cookie. Each webapp
will re-write the cookie's value to
hold that webapp's session id, and
they are all different.
When this is enabled and servlets in
different webapps are used, requests
from the same user to different
servlets will end up overwriting the
cookie so that when the servlet is
again interacted with it will create
a new session and loose the session it
had already set up.
If emptySessionPath is not set, there
are multiple cookies in the browser,
one for each webapp (none at the
root), so different webapps are not
re-writing each other's cookie as
above.
JSESSIONID is the ID Session for your Webapp. See a full explanation here.
Update: This information about usage is somewhat outdated - see here for a more up-to-date information on how to set the Session path also for recent tomcat.
If emptySessionPath is set to true, it will eliminate the context path from JSESSIONID cookie.It will set a cookie path to /.This attribute can be used for cross application autehentication mechanism.
Session are, as you probably know, often maintained by a cookie. A cookie has two values that determines whether they should be returned by the browser for a certain request, cookieDomain and cookiePath. The cookiePath must match that of the request.
A request is made for
/some/request/for/this.html
Cookie would be returned with cookie path:
/
/some
/some/request
But not for cookie path:
/other
By spec, a session is not shared between different web applications, so if you have web application foo.war deployed under /foo, the session cookie path would, by default be set to /foo.
It seems Connector.emptySessionPath is a protected variable on Connector. I haven't read the code - but I guess it has something to do with Tomcat's single sign on or sharing sessions, where you login to one context and are authenticated in all - in which case the cookie path must be / for the session cookies.
Just in case, for the web_app version 3.0, the cookie configuration is standarized, so the equivalent to the AJP's emptySessionPath in webapp 3.0 is:
<session-config>
<cookie-config>
<path>/</path>
<secure>true</secure>
</cookie-config>
</session-config>

Categories