| | |||||
| ||||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| Munky Designs Join Date: May 2005
Posts: 996
![]() ![]() ![]() | 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;
} ????: NamePros.com http://www.namepros.com/programming/395341-resolved-problems-with-serialize-and-unserialize.html 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 Join Date: Aug 2007
Posts: 2,172
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | First thing, look at unserialize error messages: Code: list($u, $c) = unserialize($cookie);
__________________ ______________________________________ Help with crosswords http://lettercombination.com Pitfalls of Java http://javasyntax.com _______________ f o r . s a l e ______________ |
| |
| | #4 (permalink) |
| Senior Member Join Date: Aug 2007
Posts: 2,172
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Can you paste the serialized cookie here?
__________________ ______________________________________ Help with crosswords http://lettercombination.com Pitfalls of Java http://javasyntax.com _______________ f o r . s a l e ______________ |
| |
| | THREAD STARTER #6 (permalink) |
| Munky Designs Join Date: May 2005
Posts: 996
![]() ![]() ![]() | 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: |
| |
| | #8 (permalink) |
| Danltn.com Join Date: May 2007 Location: Danltn.com / Nottingham, UK
Posts: 1,201
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | 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 02:18 PM.
|
| |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| |