RE: [PHP-WIN] newbie cookie question - Conclusion

From: Date: Tue, 05 Dec 2000 14:57:58 +0000
Subject: RE: [PHP-WIN] newbie cookie question - Conclusion
Groups: php.windows 
Request: Send a blank email to php-windows+get-4300@lists.php.net to get a copy of this message
I never tried setting global, because I wanted to keep global clutter to a minimum. However, I did find out what my problem was. For ease, I was developing on the same system the web server and mysql were on. I accessed a web page, entered form data and upon submision a php script was run which would authenticate, set cookies and pass the appropriate header along based on authentication. At this point, I was trying to access cookie data and could not. The reason being was because I was accessing the first web page via "localhost" instead of systems IP. This would set cookies under 'localhost' and when the script passed the header along after authentication it used the IP. SO basically the problem seemed to be that the cookies were not found. Once I accessed the first login page by entering the IP in the URL instead of localhost, the cookies were set properly and retrieved easily. Thanks one and all for your insight. Larry Hotchkiss On Tuesday, December 05, 2000 2:07 AM, patrik.lindstrom@spectronic.se [SMTP:patrik.lindstrom@spectronic.se] wrote: > Hi Larry! > > I had the same problem you have, but finally I found my problem: > I used the $HTTP_COOKIE_VARS[cookiename] in a function, but to get that to work > you must declare the variable as global, so I copied a function from a tutorial: > > function ReadCookie($name) > { > global $HTTP_COOKIE_VARS; > return $HTTP_COOKIE_VARS[$name]; > } > > function myfunction() > { > $cookie_user = ReadCookie("cookie_user"); > > #cookie read, continue > } > > > NOTE: it should be ok to declare the $cookie_name as global in the function like > this: > > function myfunction() > { > global $cookie_user; > > #cookie read, continue > } > > I didn't try it but it should work. > ***************************************************** > Patrik Lindstrom > Spectronic Research AB > Tel: +46 42 25 20 00 > Fax: +46 42 15 68 32 > Internet Address: patrik.lindstrom@spectronic.se > Home Page: http://www.spectronic.se > ***************************************************** > > -- > PHP Windows Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-windows-unsubscribe@lists.php.net > For additional commands, e-mail: php-windows-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.windows (#4300) next »