Codeigniter本地会话或ci会话库 [英] Codeigniter native session or ci session library

查看:140
本文介绍了Codeigniter本地会话或ci会话库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立了一个关于运动的一个非常小的社交网站。



我想问一个更有经验的开发者,如果更好地使用本地会话或ci会话库?

感谢您的选择

解决方案

CI会话库将帮助您快速完成,让您比本地会话更灵活。请记住,CI_Session类是相当偏执;您可能会遇到一些意外的会话到期,特别是对于AJAX重型应用程序。



我建议您使用CI会话,并附上以下警告:


  1. 不要自动加载会话类,因为在某些情况下,您可能希望忽略会话续订。

  2. 可以避免AJAX请求的会话类(如果您绝对需要它,则需要检查 sess_update()函数以防止意外到期)

  3. 您不应通过CI动态加载图片,但有些情况下需要。


  4. 此外,如果您需要更多的风险,还需要在表格中存储会话。存储比cookie允许(4KB,我想;你会使用它加速更快)。也许还要去一个数据库,并与它完成。


    Im building a really small social site about sports.

    And i would like to ask a more experienced developer, if it would be better to use native session or ci session library? and if ci library it it better to use the databse store?

    Thank you for your options

    解决方案

    The CI session library will get you up and going very quickly, giving you greater flexibility than native sessions. Keep in mind, though, that the CI_Session class is pretty paranoid; you might get some unexpected session expiration, particularly with AJAX-heavy applications.

    I recommend going with CI sessions, with the following caveats:

    1. Don't autoload the session class, as you'll probably want to ignore session renewal in some instances.
    2. As best you can, avoid the session class for AJAX requests (if you absolutely need it, you'll need to overhaul the sess_update() function to prevent unexpected expirations)
    3. You shouldn't be loading images dynamically through CI, but there are cases where it's needed. The same issues apply here as with AJAX requests.

    Additionally, you'll need to store sessions in a table if you risk needing more storage than cookies allow (4KB, I think; you'll use it up even faster with encryption). Might as well go with a database and be done with it.

    这篇关于Codeigniter本地会话或ci会话库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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