# Cleaning session variables when going to another link of the website

**URL:** <https://www.ruby-forum.com/t/cleaning-session-variables-when-going-to-another-link-of-the-website/155252>\
**Category:** Rails\
**Created:** [December 9, 2008, 9:16pm UTC](https://www.ruby-forum.com/t/cleaning-session-variables-when-going-to-another-link-of-the-website/155252 "2008-12-09T21:16:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![The\_N](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/edb3f5/32.png) [@The\_N](https://www.ruby-forum.com/u/The_N)\
**Post date:** [December 9, 2008, 9:16pm UTC](https://www.ruby-forum.com/t/cleaning-session-variables-when-going-to-another-link-of-the-website/155252/1 "2008-12-09T21:16:50Z")

</div>

Hi there!

I wish to set my session variables to null when click on a link of my  
Rails website. My major problem is this: when I click on a link and  
then return to the previous view, my session variables still remain,  
unless I click on a cleaning button where I set my variables to null  
(nil) (via a method called action, set in the forms)

This is a problem when dealing with a lot of users. I type something  
on a text field and when I click on the submit button, it saves on a  
session variable and then it shows on the field as a preset value.  
Then I click on a link of my website, and I suddenly have the idea of  
returning to my previous view, via click a link. And instead of  
erasing the value, it’s still there. Unless I click on another button  
to erase the value of the session variable, It’s impossible to erase  
it when going somewhere else.

I need help here. How do I clean those variables in that case? (When I  
click to another link, not a button.)

An example of what I’m talking about is this: session[:variable]. I  
can’t erase it.

Greetings…

The N.
