我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

在单个cookie中存储和更新多个值

How can I store multiple values in a single cookie and keep adding more values in the same cookie.

For example:

If a user_id 1 votes a post_id 1, i want to store (1, 1) in the cookie.

If the user_id 1 votes a post_id 2, I want to update the same cookie with values (1,2).

Thanks.

use json to store array in single cookie

set cookie:

setcookie("myCookie", json_encode(array(1, 2)));

get cookie:

print_r(json_encode($_COOKIE["myCookie"]));

近期文章

  • 在http中使用http:// forward slashes str_replace()替换本地路径反斜杠
  • PHP Azure表存储过滤器对除分区键以外的列进行过滤
  • 我的PHP代码不会让我插入到我的mysql表中
  • too long
  • 无法从php中的while循环中获取值
  • 我需要将视频文件扩展名更改为mp4 [关闭]
  • 在PHP中间隔的舍入时间
  • Phonegap Project不是通过php脚本创建的
  • 使用Js更改选择选项的值而不刷新页面
  • 在wordpress中动态调用另一页面中的页面内容
  • INSERT INTO行数+ 1 [关闭]
  • 提交后重定向表单
  • SQL IF EXISTS覆盖错误
  • Roundcube登录“Tabbing”[关闭]
  • 以编程方式确定搜索操作的数据大小(以字节为单位)
  • 为什么php exec()失败.tex→xelatex→.pdf,但是成功.tex→xelatex→.xdv→xdvipdfmx→.pdf?
  • 联系表格7隐藏空场标签
  • 部署Kohana 3.3时出现错误500
  • jQuery帖子没有从PHP文件加载
  • 无法让我的PHP脚本从AJAX执行

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华