Mixing CI Session and PHP Sessions - 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: Mixing CI Session and PHP Sessions (/showthread.php?tid=42569) |
Mixing CI Session and PHP Sessions - El Forum - 06-10-2011 [eluser]ryan656[/eluser] Is there any reason why it would be "bad" to mix sessions? I am storing a bunch of arrays inside session vars and codeigniter doesn't let you access them the same way that native sessions do, for example: Code: //Array I know it doesn't seem like a huge deal but it annoys the shit out of me that I can't access the values with one line using CI sessions. I am set on using native sessions but the user system and a few other components of the application are already using CI sessions and I don't feel like converting them for this one project. So again, is there any reason (security, performance, etc.) that this is a bad idea? Or maybe (just thought of this right now) there is third-party session library for CI that allows this? Thanks, Ryan Mixing CI Session and PHP Sessions - El Forum - 06-11-2011 [eluser]WanWizard[/eluser] Try to solve these issues the CI way, instead of trying to work around it, and make your life complicated. Extend the session library, by creating a MY_Session.php in application/libraries: Code: <?php This will allow you to request array elements like so Code: $result = $this->session->userdata('ar.key2'); Mixing CI Session and PHP Sessions - El Forum - 06-11-2011 [eluser]ryan656[/eluser] Awesome, thank you! Ideally I would have kept it all CI with something like what you posted, but I'm not that great at OO/CI so I figured it would be easier/quicker to use the sessions I'm familiar with. This concept helps me out in a few different ways though so I really appreciate it. Since you seem to be pretty smart with PHP and CI, if you don't mind maybe you can help me with my other post here on the forums. I am trying to allow user generated content (WYSIWYG editor from CMS) to be parsed for a template variable like {block=block_id} and execute a PHP function when it's found. It's part of a "static blocks" feature I'm trying to implement for a CMS. Any help would be GREATLY appreciated! Thanks, Ryan Mixing CI Session and PHP Sessions - El Forum - 06-12-2011 [eluser]WanWizard[/eluser] See my response in that thread. |