php 如何清除symfony2中的会话变量

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12067174/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 02:44:37  来源:igfitidea点击:

How to clear session variables in symfony2

phpsymfony

提问by Mirage

I am setting session variable with this

我正在用这个设置会话变量

$session->get('user_id');

I want to clear all session data or single variable. How can i do that

我想清除所有会话数据或单个变量。我怎样才能做到这一点

回答by NHG

To clear all session data (attributes) you should use clear. Example:

要清除所有会话数据(属性),您应该使用clear。例子:

$session->clear();

Please also see Symfony session attributes documentation.

另请参阅Symfony 会话属性文档