用PHP加密Cookie [英] Encrypting cookies in PHP

查看:72
本文介绍了用PHP加密Cookie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何在PHP中加密和解密Cookie的值(加密的安全性如何?)

How can i encrypt and later decrypt a value of a cookie in PHP (how secure will the encryption be )

推荐答案

我不能简单地想到加密cookie中的数据很有用的情况。如果您想保留有关用户或其偏好,信息等的机密数据,则将其存储在服务器上的文件中,会话中或数据库中,而不是客户端计算机中。

I can not simply think of a situation where encrypting data in the cookie is useful. If you want to retain secret data about the user or his preferences, information, whatever, then store it on the server in files, in the session or in the database, but not in the client's computer.

另一方面,如果创建身份验证,则应该使用会话而不是创建秘密的加密cookie值。会话并不是一无所获的,而是可以解决的问题。

On the other hand, if you creating an authentication, then you should use sessions instead of creating secret encrypted cookie values. Sessions weren't implemented for nothing, they are the way to go.

这篇关于用PHP加密Cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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