PHP session_start()函数:为什么每次使用与PHP会话相关的东西时都需要它 [英] PHP session_start() function: Why I need it everytime I use anything related to PHP sessions

查看:79
本文介绍了PHP session_start()函数:为什么每次使用与PHP会话相关的东西时都需要它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要从我的网站注销用户,我将页面重定向到使用session_destroy()函数的logout.php.即使在这里,没有session_start()功能也无法使用注销功能.通过在session_destroy()函数之前添加session_start()函数,我可以成功注销用户.

For logging out a user from my website, I am redirecting the page to logout.php where I am using session_destroy() function. Even there also, logout functionality is not working without session_start() function. By adding session_start() function before session_destroy() function, I am able to logout the user successfully.

为什么我每次都要在与会话相关的页面中使用session_start()函数?

Why do I need to use session_start() function everytime and in every page where I am doing something related to sessions?

推荐答案

session_destroy()破坏了活动会话.如果您没有初始化会话,那么将没有任何东西可以破坏.

session_destroy() destroys the active session. If you do not initialized the session, there will be nothing to be destroyed.

这篇关于PHP session_start()函数:为什么每次使用与PHP会话相关的东西时都需要它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆