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
How to clear session variables in symfony2
提问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 gaurang171
Visit this link
访问此链接
http://api.symfony.com/master/Symfony/Component/HttpFoundation/Session/Session.html#remove%28%29
http://api.symfony.com/master/Symfony/Component/HttpFoundation/Session/Session.html#remove%28%29
$session->remove('user_id');
$session->remove('user_id');
回答by NHG
To clear all session data (attributes) you should use clear. Example:
要清除所有会话数据(属性),您应该使用clear。例子:
$session->clear();
Please also see Symfony session attributes documentation.
另请参阅Symfony 会话属性文档。

