从多键cookie中获取值

时间:2022-03-13 17:22:15

I want to get a value from a multikey cookie! Here's how i set my cookie:

我想从多键cookie中获取值!这是我设置我的cookie的方式:

setcookie("crea_camp[nome]", $nome, 0);
setcookie("crea_camp[admin]", $admin, 0);
setcookie("crea_camp[password]", $password, 0);
setcookie("crea_camp[n_part]", $n_part, 0);
setcookie("crea_camp[squadra]", $squadra, 0);

Now i want to get the value from the cookie n_part:

现在我想从cookie n_part获取值:

$n_part =$_COOKIE["crea_camp[n_part]"];

but it doesn't get the value!

但它没有得到价值!

Then other problem: all of those values I have to put them into a database, how can I do it in a fast way?

然后是其他问题:我必须将它们放入数据库中的所有这些值,我该如何快速地完成它?

1 个解决方案

#1


0  

Perhaps it's $n_part = $_COOKIE['crea_camp']['n_part'];.

也许它是$ n_part = $ _COOKIE ['crea_camp'] ['n_part'] ;.

You may use print_r() or var_dump() to see the contents of a variable, for instance print_r($_COOKIE); and check what the key names are.

您可以使用print_r()或var_dump()来查看变量的内容,例如print_r($ _ COOKIE);并检查键名是什么。

You can as well always check what cookies are set/sent back in/from the browser using the respective developer tools (Firebug, Firefox Dev Tools, Chrome Dev Tools, etc.).

您还可以使用相应的开发人员工具(Firebug,Firefox开发工具,Chrome开发工具等)始终检查在浏览器中设置/发送的cookie。

#1


0  

Perhaps it's $n_part = $_COOKIE['crea_camp']['n_part'];.

也许它是$ n_part = $ _COOKIE ['crea_camp'] ['n_part'] ;.

You may use print_r() or var_dump() to see the contents of a variable, for instance print_r($_COOKIE); and check what the key names are.

您可以使用print_r()或var_dump()来查看变量的内容,例如print_r($ _ COOKIE);并检查键名是什么。

You can as well always check what cookies are set/sent back in/from the browser using the respective developer tools (Firebug, Firefox Dev Tools, Chrome Dev Tools, etc.).

您还可以使用相应的开发人员工具(Firebug,Firefox开发工具,Chrome开发工具等)始终检查在浏览器中设置/发送的cookie。