CodeIgniter Forums
session destroyed by anchor! - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: session destroyed by anchor! (/showthread.php?tid=2661)



session destroyed by anchor! - El Forum - 08-17-2007

[eluser]ph1k3l3d[/eluser]
Hello,

My first time, but I am not shy.

Straight to my issue, I have a session (CI session with DB) that holds data from a multi-page form.

All is well unless I put an <a href="somesite.com">Link</a> into the session. (Part of the form is to allow text and links).

If I have a peek at the session immediately after writing the link to it, I see it but at the next page, when more data is added all of the previous stuff I put in there has gone and only the new stuff is visible.

I have tried addslashes, htmlentities, htmlspecialchrs and all that good cleaning PHP stuff but I get the same result every time. If I enter just plain text into the form I get right through the process without a grumble.

I have searched the forums for any info but can't seem to find anything relating to this and its friday, I need stress free beer later so I want to get this sorted and get to the pub. Anyone have any ideas?

Cheers


session destroyed by anchor! - El Forum - 08-17-2007

[eluser]coolfactor[/eluser]
Try base64_encode. Takes up more room, but would solve your problem. Keep in mind that CI's session data is stored in the cookie by default, which doesn't allow you much room at all. You might consider using PHP's $_SESSION, which is a perfectly valid way to store session data in a PHP application, even CI. If the cookie data gets too big, it would get corrupted. That might be what happened for you.


session destroyed by anchor! - El Forum - 08-17-2007

[eluser]ph1k3l3d[/eluser]
Thanks coolfactor,

base64_encode does indeed sort out the issue, I am still puzzled as to why it breaks though. My cookies were still well under 4k in my testing so there shouldnt have been any size issues there. I may go back to standard PHP $_SESSION as you suggest, I am familiar with all that but was trying to use as much of this great framework as possible.

Least I can enjoy my beer now Smile

Cheers!


session destroyed by anchor! - El Forum - 08-17-2007

[eluser]Michael Wales[/eluser]
Look in the wiki - there are a lot of drop-in replacements for CI's session handling that will let you use normal PHP Sessions, as well as quite a few new features.


session destroyed by anchor! - El Forum - 08-17-2007

[eluser]ph1k3l3d[/eluser]
Thank you walesmd, I will have a read.


session destroyed by anchor! - El Forum - 08-17-2007

[eluser]alpar[/eluser]
put there one that is compatible with the original CI session (in that you can replace the original and your existing code will still work), you would probably like that if you have done some work already, it stores the info in the database, so you don't have a size limit, and has some security add-ons.

Enjoy your beer :d


session destroyed by anchor! - El Forum - 08-17-2007

[eluser]ph1k3l3d[/eluser]
Hey Alpar,

I ended up dropping in the OB_session library, I like the DB integration and the fact I can still use the CI_session commands, got it up and running in a few minutes and it works a treat.

Now to find my wallet, there is ale to be drunk, thanks all have a good weekend Smile