Unset session data?

I’m storing a redirect url in my session, but I’d like to delete it from
the session when I’m done with it. CGI::Session doesn’t seem to have a
way to delete key-value pairs. I found this method by Google…

session.model.data.delete(:redirect_url)

…and it works (I’m using ActiveRecordStore), but it’s ugly and seems
likely to fail in the future if sessions change. Is there a better way?

session.model.data.delete(:redirect_url)

…and it works (I’m using ActiveRecordStore), but it’s ugly and seems
likely to fail in the future if sessions change. Is there a better way?

Will the following not work for what you need?

session[:redirect_url] = nil

Curtis S. wrote:

Will the following not work for what you need?
session[:redirect_url] = nil

It changes the key’s value to nil, but leaves the key in the “hash”. If
I’m done with it, I’d rather have it gone.