Satchel
Satchel

Reputation: 16724

session['value'] = nil doesn't seem to stay empty in Rails 3?

My controller tries to set the session value to nil. Within the controller, it works, but then we I reload the browser (not quit), the session value comes back?

How can I keep it cleared out and empty? Is it possible the browser still stores that session even though I set it = nil?

Upvotes: 0

Views: 1191

Answers (2)

Kelvin
Kelvin

Reputation: 20857

If you're using cookie store for the session, maybe the changed session isn't making it to the browser. If this is the case, the browser still has the old value in the cookie. When the page is reloaded, the browser will send the cookie to rails, which will restore the old value.

It's hard to say more without seeing your controller action.

Upvotes: 0

emrass
emrass

Reputation: 6444

Setting the variable to nil keeps the session. Try to call

reset_session

in your controller to get rid of the whole session.

Nonetheless, even after setting the value to nil, it should not come up in your next request. Make sure you are not setting it back, e.g. in a before_filter.

Upvotes: 1

Related Questions