在Cookie中存储嵌套数组 [英] Storing nested arrays in a cookie

查看:271
本文介绍了在Cookie中存储嵌套数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在cookie中存储嵌套数组。我决定将数组存储为JSON字符串。但是,我收到此警告:

I am trying to store nested arrays in a cookie. I decided to store the array as a JSON string. However, I am getting this warning:

PHP警告:Cookie值不能包含任何以下',; \t\r\\\
\013\014'in foobar.php

PHP Warning: Cookie values can not contain any of the following ',; \t\r\n\013\014' in foobar.php

有一种推荐的方式在Cookie中存储嵌套数组? p>

Is there a recommended way of storing nested arrays in a cookie?

推荐答案

您可以使用 base64_encode() base64_decode()

You could use base64_encode() and base64_decode()

手动:


Base64编码数据比原始数据占用大约33%
的空间。

Base64-encoded data takes about 33% more space than the original data.

这篇关于在Cookie中存储嵌套数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆