【问题标题】:codeigniter encrypted string not able to decrypt after logout注销后无法解密的codeigniter加密字符串
【发布时间】:2014-07-27 06:35:55
【问题描述】:
$this->load->library('encrypt');
$encoded_string = $this->encrypt->encode('my_string_to_secure');

$this->load->library('encrypt');
$original_string_after_decode = $this->encrypt->decode('encoded_string ');

此代码正确编码和解码给定字符串

但是当我将此编码字符串设置为 cookie 并在注销后尝试解密此编码字符串时,我无法解密此

我正在使用配置文件中设置的加密密钥。

【问题讨论】:

  • 可能是您的 cookie 在注销后被销毁。在尝试解码之前检查 cookie 是否存在

标签: php codeigniter security session-cookies


【解决方案1】:

你需要把你的编码字符串存储在变量$encoded_stringtry中

$original_string_after_decode = $this->encrypt->decode($encoded_string);

更多信息:-http://ellislab.com/codeigniter/user-guide/libraries/encryption.html

【讨论】:

  • 先生,我已经这样做了,我在这里编辑了代码以使其更具可读性
  • 使用 session 代替 cookie 并且不销毁所有 session 只销毁用户 session
猜你喜欢
  • 2016-02-25
  • 2018-05-19
  • 2023-03-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-12-27
  • 1970-01-01
  • 2021-09-11
相关资源
最近更新 更多