Cookie question? - 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: Cookie question? (/showthread.php?tid=40245) |
Cookie question? - El Forum - 04-03-2011 [eluser]R_Nelson[/eluser] I'm creating a user Cookie that looks like this : Code: $cookie = array( My question is will it work if i add an array in where $id is? the array would be something like Code: $user = array ( Im getting error Quote:A PHP Error was encountered Cookie question? - El Forum - 04-03-2011 [eluser]InsiteFX[/eluser] Code: $user = array ( You may want to serialize and unserialize your $cookie_data You view the session.php class to see how it is done! InsiteFX Cookie question? - El Forum - 04-03-2011 [eluser]R_Nelson[/eluser] Quote:You may want to serialize and unserialize your $cookie_data that's so it encodes it right? Cookie question? - El Forum - 04-03-2011 [eluser]R_Nelson[/eluser] if i create the cookie using $cookie_data wouldn't i be missing the name and expire? Cookie question? - El Forum - 04-03-2011 [eluser]InsiteFX[/eluser] 1) Yes thats to encode it. 2) No, the only thing you put in $cookie_data is the values you want to store. Code: $cookie = array( InsiteFX Cookie question? - El Forum - 04-03-2011 [eluser]R_Nelson[/eluser] thats how i got the error in the first place! Cookie question? - El Forum - 04-03-2011 [eluser]InsiteFX[/eluser] Did try to serialize it first? InsiteFX Cookie question? - El Forum - 04-03-2011 [eluser]R_Nelson[/eluser] no i did not. would that make a difference? Cookie question? - El Forum - 04-04-2011 [eluser]InsiteFX[/eluser] My fault, sorry The input class is using codeigniters set_cookie but the one in the session library is using php's setcookie So this line should be: Code: setcookie($cookie); // not set_cookie I edited the above code. I would encode and encrypt the cookie, you can see how they do it in the system/libraries/session.php file _set_cookie InsiteFX Cookie question? - El Forum - 04-04-2011 [eluser]R_Nelson[/eluser] the encrypt thing works just fine for session cookies but it dose not encrypt the normal user cookies for login i supouse i could 5d5 them or sha1 them then compare them to the database one md5 or sha1 |