Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_php thread: php cookie problem


Message #1 by "Anuruddha Perera" <myinformix@r...> on Thu, 13 Feb 2003 23:58:16

First, *PLEASE* don't mail me off the list for PHP assistance.  If I have time
to help you, I'll help you here.


That said:


> I installed PHP 4.3.0 on Windows2000+IIS.
> When I tried to read my cookie set with the following code I get an error
> message.
>
>    ob_start();
>    session_start();
>  if (!isset($jcid) and (!isset($CurrDmn)))
>   {    $domain ="mmm";
>        $page ="test";
> 	setcookie("CurrDmn",$dmnid,0,'/phpintratnet/','mydomain.com',0);
> 	setcookie("jcid",$page,0,"/phpintratnet/",$domain,0);
> 	header("Location:"."http://".$website."/redirect.php");
>   }
>
> The error message I get after the redirection page(i.e. redirect.php) is...
> ===================
> Notice: Undefined index: jcid in
> C:\Inetpub\wwwroot\phpintranet\redirect.php on line 2
> ===================
>
> Contents of redirect.php
> -----------------------
> Line1. $mycookie = $_COOKIE["jcid"];
> Line2. echo $mycookie;
>
> -----------------------

The problem is that you're attempting to access an array index that's not
defined.  You can get rid of the warning by changing your error_reporting
setting in php.ini, but I think you're better off calling setcookie() with the
correct parameters.

I can't help but assume that "mmm" is a fake value for $domain, and that you
have a real value that you pass into it.

You should read the manual at http://www.php.net/setcookie closely, as it
describes (and provides lots of useful links and user comments) about working
with cookies.

Also, read through http://www.php.net/features.cookies



Take care,

Nik


  Return to Index