_SESSION 变量不起作用 [英] _SESSION variable not working
本文介绍了_SESSION 变量不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个 PHP 脚本,我尝试在 HTML 标头开始之前获取会话变量.
I have a PHP script where I try to get a session variable before the HTML headers start.
如果我在 HTML 正文的某处使用 _SESSION
变量,由于某种原因它会起作用.但是如果我在 HTML 开始之前使用 _SESSION
变量,我无法从中获取值.
If I use the _SESSION
variable somewhere in the body of the HTML, for some reason it works. But if I use the _SESSION
variable before the HTML starts, I can't get the values out of it.
有谁知道为什么会发生这种情况以及我如何从会话变量中获取值?
Would anyone know why this is happening and how I can get the values out of the session variable?
推荐答案
Put session_start();
在使用 $_SESSION
变量之前.
Put session_start();
before using $_SESSION
variable.
这篇关于_SESSION 变量不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文