简体   繁体   English

在PHP中检索Cookie值

[英]Retrieve cookie VALUE in PHP

I'm trying to retrieve the cookie's value by simply calling its indexed position in the array, which is 1. However, I'm getting an error message saying 1 is an undefined offset? 我试图通过简单地调用其在数组中的索引位置(即1)来检索Cookie的值。但是,我收到一条错误消息,说1是未定义的偏移量? When I know for a fact it is in position 1. Am I missing something?? 当我知道某个事实在位置1时,我是否缺少某些东西?

$query = "SELECT * FROM basketID" . $_COOKIE[1];

I've set the cookie like this 我像这样设置了cookie

setcookie('visitUid',$uid,time()+60*60*24*7, '/');

$uid is a randomly generated number btw. $ uid是一个随机生成的数字btw。

$_COOKIE['visitUid']是您要寻找的

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM