| |||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | #1 (permalink) |
| Munky Designs | problems with serialize and unserialize hey, ok, I am saving 2 values in my cookie, like so: Code: $cookie = @serialize(array($u, $c));
setcookie("siteLogin", $cookie, time() + 36000, "/");
now, when I come to extract it, I have this: Code: if (isset($_COOKIE['siteLogin'])){
echo $_COOKIE['siteLogin']."<br />";
echo unserialize($cookie)."<br />";
list($u, $c) = @unserialize($cookie);
echo "username: ".$u." cookie: ".$c;
}
here is a test url: http://munkydesigns.co.uk/ScriptsNew/login.php u: username p: password make sure you check remember me lol thanks in advance
__________________ |
| |
| | #2 (permalink) |
| Senior Member | First thing, look at unserialize error messages: Code: list($u, $c) = unserialize($cookie);
__________________ Time After Leisure & Events discussions eBay auction aqnu, pzpy, vqqr.com 16 llll.com start $.95 |
| |
| | #4 (permalink) |
| Senior Member | Can you paste the serialized cookie here?
__________________ Time After Leisure & Events discussions eBay auction aqnu, pzpy, vqqr.com 16 llll.com start $.95 |
| |
| | #5 (permalink) |
| NamePros Regular | You are referring to a variable $cookie which doesnt seem to be set unserialize($_COOKIE['siteLogin']); should do it.
__________________ Paris loves CityPics muov.com • qeww.com • sejz.com • viuo.com • vuav.com • wzeo.com • xeib.com • xueo.com -- Do not let others be treated this way! |
| |
| | #6 (permalink) |
| Munky Designs | Jido, here is the serialized cookie: a:2:{i:0;s:8:\"username\";i:1;s:32:\"29ef5859fbfe3 4e0918bdec7ec00a988\";} Neroux, good spot haha. thats because I copied and pasted the snippet from the actual function, with $cookie as a parameter. However, even as : PHP Code:
__________________ |
| |
| | #7 (permalink) |
| NamePros Regular | I know you said the cookie contains the value, but can you check it once again? The reason is, in your example I am not even getting the cookie but only the session cookie.
__________________ Paris loves CityPics muov.com • qeww.com • sejz.com • viuo.com • vuav.com • wzeo.com • xeib.com • xueo.com -- Do not let others be treated this way! |
| |
| | #8 (permalink) |
| Danltn.com | Try this, it's ugly and someone will probably yell at me. But it seems to work. PHP Code:
__________________ Last edited by Danltn; 11-14-2007 at 01:18 PM. |
| |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| |