note 16944 added to function.setcookie

From: Date: Mon, 19 Nov 2001 22:04:37 +0000
Subject: note 16944 added to function.setcookie
Groups: php.notes 
Request: Send a blank email to php-notes+get-21029@lists.php.net to get a copy of this message
I have finally gotten my cookies to work consistently. This has been tested on IE5+ and NS6. I use cookies to set parameters for each user. I am using session support via database and passing URLs with sessionID. I change the cookie by referencing another page via a HREF link. I suppose it could be done by calling the original page, and I plan to try that next. (IMA NEWBIE) Here is the link to the "setcookie" page: (print) "<A HREF=./setversion.php?&rv=$version_name&SESSION_ID=$SESSION_ID>$version_name</A>"; Here is the "setcookie" page: <? include "config.inc.php"; $expires = time()+(60*60*34*265*10); setcookie($VERSION_SELECTED, $rv, $expires); Header("Location: index.php"); exit; ?> Here is the config.inc.php page: <? $SITE_NAME = "SITENAME"; $COOKIE_PREFIX = "SITENAME"; $VERSION_SELECTED = $COOKIE_PREFIX."VERSION"; ?> IT SEEMS TO BE VERY IMPORTANT TO HAVE THE SITENAME URL AND THE COOKIE PREFIX SET TO IDENTICAL VALUES! IF YOU DONT'T HAVE THEM THE SAME, SETCOOKIE IS "BUGGY". TRY IT, YOU'LL LIKE IT! :) Mikey -- http://www.php.net/manual/en/function.setcookie.php http://master.php.net/manage/user-notes.php?action=edit+16944 http://master.php.net/manage/user-notes.php?action=delete+16944 http://master.php.net/manage/user-notes.php?action=reject+16944

« previous php.notes (#21029) next »