在$ _GET设置$ _SESSION不会工作 [英] on $_GET set $_SESSION wont work
问题描述
我需要得到最后一个非空值 $ _ GET ['id_item']
有
在session_start();
if(!isset($ _ SESSION ['id_item'])|| $ _SESSION ['id_item'] ===''||(isset($ _ GET ['id_item'])& &!$ _ GET ['id_item'] ==='')){
$ _SESSION ['id_item'] = $ _GET ['id_item'];
} else {
/ *不需要更新* /
}
echo $ _SESSION ['id_item'] / *总是空白:S * /
和 var_dump($ _ GET)
输出:
array(1){[id_item] =>字符串(2)50}
任何想法为什么 $ _ SESSION
没有保存?
修正此问题:
或者您可以使用: I need to get the last non-empty value that And Any idea why the fix this: or you can use:
这篇关于在$ _GET设置$ _SESSION不会工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! $ _ SESSION ['id_item'] ===''
$ $ $ $ $ $ c $ empty $ _SESSION ['id_item'])
$_GET['id_item']
hadsession_start();
if(!isset($_SESSION['id_item']) || $_SESSION['id_item']==='' || ( isset($_GET['id_item']) && !$_GET['id_item'] === '' )){
$_SESSION['id_item'] = $_GET['id_item'];
}else{
/*no need to update*/
}
echo $_SESSION['id_item'] /* Allways in blank :S */
var_dump($_GET)
outputs:array(1) { ["id_item"]=> string(2) "50" }
$_SESSION
is not saved?$_SESSION['id_item']==''
to $_SESSION['id_item']===''
empty($_SESSION['id_item'])