douceng7070
2015-09-22 08:45
浏览 48
已采纳

迁移CodeIgniter3会话后端

Currently I use the database backend for CodeIgniter session storage. I would like to move away from storing session information in the database, and would like to switch to using the filesystem backend. However, I would like not to lose all my sessions. Is there a way to migrate from one to the other without losing session data?

图片转代码服务由CSDN问答提供 功能建议

目前我使用数据库后端进行CodeIgniter会话存储。 我想放弃在数据库中存储会话信息,并希望切换到使用文件系统后端。 但是,我不想失去我所有的课程。 有没有办法从一个迁移到另一个而不会丢失会话数据?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dongnao2048 2015-09-22 08:55
    已采纳

    Usual way how to do this is to create transition session handler that would look first into one storage (I personally prefer the new one - filesystem) and if it won't find it there, it will look into the old one (database).

    That results in a temporary state where you existing sessions will be still read from database. When they expire, new ones will be created on filesystem.

    When you will be sure there are no more active sessions in database, you can switch session handler for the one that works only with filesystem.

    Look at https://secure.php.net/manual/en/session.customhandler.php for more details how to implement custom handler.

    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题