---
title: "How to use invalidate session?"  
description: "How to use invalidate session?"  
author: "Samuel Fernandes"  
published: 2014-10-06  
updated: 2014-10-06  
canonical: https://www.mindstick.com/forum/2313/how-to-use-invalidate-session  
category: "cold fusion"  
tags: ["c#", "cold fusion"]  
reading_time: 1 minute  

---

# How to use invalidate session?

When do you call getPageContext().getSession().invalidate()?

I tried calling that at the logout [page](https://www.mindstick.com/articles/13031/why-to-make-a-wikipedia-page), then cflocation it back to the main page, and it throws exception.

How to assign a new [session](https://www.mindstick.com/articles/12042/session-in-c-sharp) [right](https://www.mindstick.com/articles/12766/check-whether-you-are-doing-digital-transformation-right-or-not) after?

## Replies

### Reply by Anonymous User

getPageContext().getSession().invalidate() will invalidate the session, subsequent request with that sessionID will get an error trying to access the Session scope but the memory will not be reclaimed until the actual session timeout.

What you can do is session.setMaxInactiveInterval(int) set it to very a low number in ms so it expires right away and release the memory. Then do a cflocation and for safe mesure use addToken="no"


---

Original Source: https://www.mindstick.com/forum/2313/how-to-use-invalidate-session

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
