【发布时间】:2012-03-10 01:25:14
【问题描述】:
我已经对 $_SESSION 和 $_COOKIE 进行了一些测试,因为它们没有按预期工作。我想知道为什么这些代码行的行为不同。
$_SESSION[1] = 'foo'; // Does not work because of the integer
$_COOKIE[1] = 'bar'; // Works
$_SESSION['foo bar'] = 'foo'; // Works with the space
$_COOKIE['foo bar'] = 'bar'; // Does not work
我原以为 $_SESSION 和 $_COOKIE 将是相同的,除了服务器端与客户端。两者还有其他区别吗?
【问题讨论】:
-
这只是一个区别,但它很重要