我可以将从javascript设置的cookie值存储到php变量中吗?

use*_*403 1 javascript php cookies

我将一个javascript值存储到cookie中,如下所示.

var headvalue = "blue";

localStorage.setItem('headvalue', headvalue );
Run Code Online (Sandbox Code Playgroud)

它可以从cookie中获取这个headvalue变量并将其存储到php变量$ headvalue中吗?如果有,怎么样?

Sha*_*tta 6

使用Javascript创建cookie:

var headvalue = "blue";
document.cookie = "headvalue="+headvalue;
Run Code Online (Sandbox Code Playgroud)

使用PHP检索它:

$headvalue = $_COOKIE["headvalue"];
Run Code Online (Sandbox Code Playgroud)