Codeigniter - Handle Sessions without cookies

2019-06-07 23:07发布

问题:

Some users might not have cookies enabled. Is there a plugin for CI that automatically generates GET-Parameters and parses those parameters (for example in the constructor of a controller)?

What would be a good CI-way of doing this?

回答1:

In CodeIgniter 3 the session library doesn't use cookies. In previous CodeIgniter versions “cookie driver” was the only option and the developers of CI have received negative feedback on not providing that option. Listening to feedback from the community, cookie driver was dropped because it is unsafe.
In CI 3 the Session library comes with 4 drivers, or storage engines, that you can use: files, database, redis, memcached.

www.codeigniter.com/userguide3/libraries/sessions.html#session-drivers



回答2:

Should state, that using params in that way would probably not be a good idea, and I've never heard of a plugin doing that. You'd probably have to deal with routing issues if you did to begin with. However, CI actually gives you a way to store session information in your database. Check out the documentation, it's easy to set up: http://codeigniter.com/user_guide/libraries/sessions.html

This is probably the better way to go, if you don't want to rely on cookies