jparker Posted May 2, 2006 Share Posted May 2, 2006 HelloI have 2 very simple scripts that sets and then gets a cookie to test to see all is workingThe set script below seems to run without problems : -<?phpsetcookie ("user", "jparker", time()+604800); ?>the get script below however doesn't work and creates an error in the apache log<?php$user = $HTTP_COOKIE_VARS["user"];echo "Hello ".$user;?>The error is : -[client 127.0.0.1] PHP Notice: Undefined variable: HTTP_COOKIE_VARS get.php on line 2Could you possible point me in the right direction on how to solve this. I'm guessing its a PHP/Apache configuration issueThanksJames Quote Link to comment https://forums.phpfreaks.com/topic/8872-cookie-problem/ Share on other sites More sharing options...
wildteen88 Posted May 2, 2006 Share Posted May 2, 2006 Dont use HTTP_*_VARS variables use the new superglobal arrays (_POST, _GET, _COOKIES, _SESSION, etc). So use the following:[code]<?php$user = $_COOKIE['user'];echo "Hello " . $user;?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/8872-cookie-problem/#findComment-32545 Share on other sites More sharing options...
jparker Posted May 2, 2006 Author Share Posted May 2, 2006 Thanks very much it has worked now.Having seen $HTTP_COOKIE_VARS in examples for retrieving cookies is this now obsolete?James Quote Link to comment https://forums.phpfreaks.com/topic/8872-cookie-problem/#findComment-32555 Share on other sites More sharing options...
wildteen88 Posted May 2, 2006 Share Posted May 2, 2006 Yes the old $HTTP_*_VARS variables will not exist as of PHP6 and they are also disabled by defualt as of PHP4.1.0. You can still use them by turning [b]register_long_arrays[/b] on in the php.ini. But they are becoming depreciated, hense why they are going to be removed as of PHP6 I believe. Quote Link to comment https://forums.phpfreaks.com/topic/8872-cookie-problem/#findComment-32660 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.