Welcome Guest, Not a member yet? Register   Sign In
Codeigniter and Cookies
#2

[eluser]Ian Jones[/eluser]
Yes you can store custom cookie data with:
Code:
$userData = array('key' => 'value', 'key' => 'value');
$this->session->set_userdata($userData);

and retrieve a value with:
Code:
$this->session->userdata('key')

You could set and retrieve values in a non-expiring cookie as you suggested, but there is a limit to how much data a cookie can store (4KB). Hopefully your 'user' won't clear their cookies either...

The alternative is to store just a user ID in the cookie, then retrieve all the custom settings which match that user ID from the database. If you can't do it in the 4KB of cookie, then the database is your best bet. The database also would help you to track how users are setting up their options, which would be useful when you come to redesign.


Messages In This Thread
Codeigniter and Cookies - by El Forum - 01-13-2010, 11:15 AM
Codeigniter and Cookies - by El Forum - 01-13-2010, 08:25 PM



Theme © iAndrew 2016 - Forum software by © MyBB