Home >Backend Development >PHP Tutorial >cookie获取问题

cookie获取问题

WBOY
WBOYOriginal
2016-06-23 14:16:361010browse

Cookie HTML

我用thinkphp框架开发,但在设置cookie时得不到cookie数组中的内容,如我的用词表有个帐号,密码,用户名等,然后我在后台设置为
$loginerInfo=$user->where("account='$userName' and password='$password'")->find();
cookie('loginerInfo',$loginerInfo,'expire=3600*30');
这样把cookie保存起来,但在html模板中如果我要直接得到用户名的内容要怎么写?
在线等高手来解答!

回复讨论(解决方案)

存cookie是先将内容编码,例如json_encode,然后读取的时候解码,例如json_decode,然后就直接在html模板中使用就好了。 

怎么用啊?我这样得不到值啊

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn