Re: cookie problem..
| From: | Joel Colombo | Date: | Sun, 23 Feb 2003 08:48:19 +0000 |
| Subject: | Re: cookie problem.. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-136709@lists.php.net to get a copy of this message | ||
make sure u run a session_start(); before anything on the page
u cant access any session vars without it.
Joel
"Terry Lau" <mufcterry@hotmail.com> wrote in message
news:F56nwpGR881Np7vXee40003fe01@hotmail.com...
> Hello,
> I want to set a cookie when I enter a text into the text field, and
it
> shows the text I submitted immediately, thus I write a sample php code
like
> this:
>
> <?php
> if (isset($HTTP_POST_VARS['Name'])) {
> setcookie("name", $HTTP_POST_VARS['Name'], time()+86400*10);
> }
> echo $name;
> ?>
> (I set the text field is Name and the data will be sent to another page)
>
> In another page, I insert <?php echo $HTTP_COOKIE_VARS['name']; ?> in the
> beginning of the code.
>
> Is the code right?
>
> Then I run the test, I enter a name into the text field and submit it. But
> it shows "Notice: Undefined index: name in ..", it can't show the name I
> submitted.
> Why?Anything wrong??
>
> Thanks!!
> Terry
>
>
>
>
> _________________________________________________________________
> ¤µ¤é¬P®y http://www.msn.com.hk/fortune/west/ ¹Bµ{
>