Session class allow for arrays? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Session class allow for arrays? (/showthread.php?tid=3507) |
Session class allow for arrays? - El Forum - 10-06-2007 [eluser]stevefink[/eluser] Hey folks, Is it possible to set a session variable to contain an array of values? I'm trying to write a profile hit counter for http://www.f1autoimports.com/inventory which admins can view in the back-end. I haven't thought of the most elegant formula for this task, but I'm thinking my best bet is to register a session with a vehicle_id. If a session exists with that vehicle_id set, do not increment the counter, else increment it. I think this will only be possible if I do something like: Code: $this->session->set_userdata('counter', $array['ids']); I'd definitely appreciate any feedback on how you folks handle something similar. - sf Session class allow for arrays? - El Forum - 10-06-2007 [eluser]llbbl[/eluser] Yes its possible. Haven't done it before in CI. http://php.about.com/od/advancedphp/ss/php_sessions_2.htm Session class allow for arrays? - El Forum - 10-06-2007 [eluser]Michael Wales[/eluser] I've been mulling over the same problem as well. For instance, how does this forum know if you've viewed a post or not? It's not based off of timestamps, it's based off of actual views. Maybe a session/database field with a delimited list of viewed item IDs (comma, pipe, whatever)? I dunno. |