note 26380 added to function.setcookie

From: Date: Tue, 29 Oct 2002 03:41:34 +0000
Subject: note 26380 added to function.setcookie
Groups: php.notes 
Request: Send a blank email to php-notes+get-38675@lists.php.net to get a copy of this message
Something to note, if you have quotes in the cookie value you set, they will be back-slashed in $_COOKIE[]. E.g.: setcookie('dialog', 'He said, "Hello."'); Then later $_COOKIE['dialog'] will have: He said, \"Hello.\" This will definately cause trouble if you're trying to serialize() and unserialize() data into a cookie. I use stripslashes() on the $_COOKIE value, though can't be certain it will handle all cases, but works so far for me. I found this behavior on both Mozilla and IE, so I don't believe it's the browser adding the back-slashes. -- http://www.php.net/manual/en/function.setcookie.php http://master.php.net/manage/user-notes.php?action=edit+26380 http://master.php.net/manage/user-notes.php?action=delete+26380 http://master.php.net/manage/user-notes.php?action=reject+26380

« previous php.notes (#38675) next »