Re: Problem while retrieving data from cookie with unserialize
| From: | Tom Rogers | Date: | Sun, 22 Jun 2003 05:11:34 +0000 |
| Subject: | Re: Problem while retrieving data from cookie with unserialize | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-152427@lists.php.net to get a copy of this message | ||
Hi,
Friday, June 20, 2003, 7:42:48 AM, you wrote:
SÖ> Hi, Im having this problem:
SÖ> I set a cookie using this:
SÖ> $sql = "UPDATE member SET cookie=$cookie WHERE
SÖ> ".
SÖ> "id = $this->id";
SÖ> $this->mysql->query($sql);
SÖ> $cookie =
SÖ> urlencode(serialize(array($_SESSION['username'], $cookie)));
SÖ> setcookie('auth', $cookie, time() + 31104000,
SÖ> '/', 'www.reddast.is');
SÖ> And then when I check the cookie using this:
SÖ> list($username, $cookie) =
SÖ> @unserialize(urldecode($cookie));
SÖ> using this query:
SÖ> "SELECT * FROM member WHERE (username = $username) AND
SÖ> (cookie = $cookie)";
SÖ> it looks like this when I debug the script and see the actual query that
SÖ> is sent to Mysql:
SÖ> "SELECT * FROM member WHERE (username = 'ofjord') AND
SÖ> (cookie = '\'86aa5f7e6469efe09a17089957f59b0f\'')";
SÖ> I hope someone has any answers on this.
SÖ> Best regards,
SÖ> Sævar Öfjörð Magnússon
SÖ> ofjord@simnet.is
SÖ> ICELAND
SÖ> --
SÖ> PHP General Mailing List (http://www.php.net/)
SÖ> To unsubscribe, visit: http://www.php.net/unsub.php
Try base64 encoding/decoding it instead of urlencode
--
regards,
Tom