From 71eb8af6099e2f94160d803d4faa15354727b656 Mon Sep 17 00:00:00 2001 From: Steve Ronderos Date: Mon, 19 Mar 2012 19:15:53 -0500 Subject: [PATCH] Fixing two small issues with invalid sessions and cookies I was encountering two small issues with the plugin. The first was that the first time I visited the application I would get an AssertionFailed exception. The second was that after a session was invalidated the application would create a duplicate session cookie, causing my session information to get lost. This happened in Chrome, not sure if that had something to do with it. It should now ensure that the cookie that is returned has the same path and host as the original cookie. Also revved the version to the next micro plus snapshot. --- DatabaseSessionGrailsPlugin.groovy | 2 +- .../grails/plugin/databasesession/SessionProxyFilter.java | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/DatabaseSessionGrailsPlugin.groovy b/DatabaseSessionGrailsPlugin.groovy index b5ea711..c9288e1 100644 --- a/DatabaseSessionGrailsPlugin.groovy +++ b/DatabaseSessionGrailsPlugin.groovy @@ -5,7 +5,7 @@ import grails.util.Metadata import org.springframework.web.filter.DelegatingFilterProxy class DatabaseSessionGrailsPlugin { - String version = '1.1.2' + String version = '1.1.3-SNAPSHOT' String grailsVersion = '1.3.3 > *' String title = 'Database Session Plugin' String author = 'Burt Beckwith' diff --git a/src/java/grails/plugin/databasesession/SessionProxyFilter.java b/src/java/grails/plugin/databasesession/SessionProxyFilter.java index a31cb6b..36d37b1 100644 --- a/src/java/grails/plugin/databasesession/SessionProxyFilter.java +++ b/src/java/grails/plugin/databasesession/SessionProxyFilter.java @@ -68,7 +68,8 @@ protected HttpSession proxySession(final boolean create, final HttpServletReques // no session cookie but do create log.debug("No session cookie but create is true, creating session"); - createSession(request, response); + sessionId = createSession(request, response); + return new SessionProxy(getServletContext(), persister, sessionId); } if (persister.isValid(sessionId)) { @@ -130,7 +131,7 @@ protected void createCookie(String sessionId, HttpServletRequest request, HttpSe } else { log.debug("Updating existing cookie with id {} to new value {}", cookie.getValue(), sessionId); - cookie.setValue(sessionId); + cookie = newCookie(sessionId, request); } response.addCookie(cookie); }