Skip to content

Commit

Permalink
Merge pull request #123 from k-r-g/sessionInvalidateFix
Browse files Browse the repository at this point in the history
When invalidating the session make it possible to start using a new one
  • Loading branch information
msmith-techempower authored Mar 24, 2023
2 parents 5c593f9 + 288d0e3 commit 2a6ab85
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
14 changes: 14 additions & 0 deletions gemini/src/main/java/com/techempower/gemini/Context.java
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,20 @@ public Session getSession(boolean create)
return this.session;
}

/**
* In addition to invalidating the session, also sets the Context.session member variable to null
* so it is re-created as needed and is available for immediate use.
*/
public void invalidateSession()
{
if (this.session != null)
{
this.session.invalidate();
}
// Rely on getSession() to create a new session as needed.
this.session = null;
}

/**
* Gets the full standard (non-secure) URL to the Servlet.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,11 +306,7 @@ public SessionNamedValues clear()
*/
public SessionNamedValues invalidate()
{
final Session session = context.getSession(false);
if (session != null)
{
session.invalidate();
}
context.invalidateSession();
return this;
}

Expand Down

0 comments on commit 2a6ab85

Please sign in to comment.