【问题标题】:Session class error that requires an encryption key in codeigniter需要在 codeigniter 中使用加密密钥的会话类错误
【发布时间】:2012-03-23 16:38:58
【问题描述】:

我是 codeigniter 的新手,并且对 php 有很好的体验。我最近遇到了一个 codeigniter 告诉我的错误

 "In order to use the Session class you are required to set an encryption key in your config file." 

我听说解决方案是粘贴

   $config['encryption_key'] = 'your_encryption_key_here';

在配置文件中。

现在我完全不知道这里发生了什么。这个加密密钥是什么?为什么会话课程需要它,有什么意义?

谢谢大家。

【问题讨论】:

    标签: php codeigniter session


    【解决方案1】:

    来自Session class documentation

    注意:即使您不使用加密会话,也必须在配置文件中设置一个加密密钥,用于帮助防止会话数据被操纵。

    此外,您不需要粘贴任何内容。 $config['encryption_key'] 已存在于 config.php 中,但设置为空字符串:

    /*
    |--------------------------------------------------------------------------
    | Encryption Key
    |--------------------------------------------------------------------------
    |
    | If you use the Encryption class or the Session class you
    | MUST set an encryption key.  See the user guide for info.
    |
    */
    $config['encryption_key'] = '';
    

    【讨论】:

    • 我们应该为自己发布在文档中清晰可见的报价投反对票:)
    • 请问加密密钥的真正意义是什么?我对这一切都不熟悉......对不起。
    • @Matt:从我上面的回答来看,关键点是to aid in preventing session data manipulation. 您可以在Encryption class documentation 中阅读更多内容。 CodeIgniter 以其高于平均水平的文档而闻名 - 我强烈建议您通读它。
    • @Colin 是的,CI 文档相当不错。人们仍然会忽略它,而不仅仅是对于原生 php 函数,人们也会忽略 php 文档。我猜有些人会变得懒惰,如果他们在视频教程中找不到解决方案,他们会来这里问这些问题。 PS 无论如何都不是针对马特的。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-15
    • 2022-12-03
    • 2010-11-06
    • 2014-05-31
    • 2014-04-19
    • 1970-01-01
    相关资源
    最近更新 更多