---
title: "rails 如何清除clear session "
author: "RunUpwind"
date: "2011-06-22T13:50:21Z"
tags: []
categories: ["编程语言"]
slug: "rails-clear-session"
draft: false
lastmod: "2011-06-22T13:50:21Z"
id: 1100814
url: "https://runupwind.iteye.com/blog/1100814"
---

参照：http://stackoverflow.com/questions/684457/how-do-you-clear-a-single-entry-from-a-ruby-on-rails-session

http://stackoverflow.com/questions/2405635/how-to-empty-destroy-a-session-in-rails

 

清除session中的单个对象:

 

```
session[:foo] = nil

session.delete :foo

session.data.delete :foo
```

 

清除当前session中的所有对象：

 

```
reset_session
```