test.php <?php header("Content-Type:text/html; charset=utf-8");if($_COOKIE("UserName"))echo $_COOKIE("UserName");else header("location:test2.php"); ?>这样测试的时候,提示: Fatal error: Function name must be a string in E:\Work\web\test1\test.php on line 4 这个什么错误?
二 设置的时候没有设置有效时间
经过http://127.0.0.1/work/web/site/main/login.php验证产生cookie再返回上一页面。这样有路径的问题?
<?php
header("Content-Type:text/html; charset=utf-8");if($_COOKIE("UserName"))echo $_COOKIE("UserName");else header("location:test2.php");
?>这样测试的时候,提示:
Fatal error: Function name must be a string in E:\Work\web\test1\test.php on line 4
这个什么错误?
应为$_COOKIE["UserName"]2、你在
http://127.0.0.1/work/web/site/main/login.php验证产生cookie
http://127.0.0.1/work/web/test1/test.php 中默认是读取不到的,除非你在设置cookie时显式指定了路径"/"
session.cookie_path = /
php.ini里这样设置的,在使用的时候也需要设置吗?
是通知php在向cookie保存sessionid的时候,声明路径为/
php都尚且如此,何况你呢?