Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何在一个 cookie 中存储多个值并在同一个cookie中不断添加更多值。
例如:
如果 user_id 1 投票 post_id 1,我想将 (1, 1) 存储在 cookie 中。
如果 user_id 1 投票 post_id 2,我想用值 (1,2) 更新相同的 cookie。
谢谢。
使用 json 将数组存储在单个 cookie 中
设置饼干:
setcookie("myCookie", json_encode(array(1, 2)));
获取饼干:
print_r(json_encode($_COOKIE["myCookie"]));