1:$HTTP_COOKIE_VARS is deprecated as of PHP 4.1.0, try $_COOKIE['pop'] instead. 2: Once the cookies have b" name="description" /> 1:$HTTP_COOKIE_VARS is deprecated as of PHP 4.1.0, try $_COOKIE['pop'] instead. 2: Once the cookies have b" />

Can't set cookies in PHP?


For some reason This php script won't echo anything:

<?php setcookie("pop",'hi',time()+604800); echo $HTTP_COOKIE_VARS['pop']; ?>


$HTTP_COOKIE_VARS is deprecated as of PHP 4.1.0, try $_COOKIE['pop'] instead.



Once the cookies have been set, they can be accessed on the <strong>next page load</strong> with the $_COOKIE or $HTTP_COOKIE_VARS arrays. Note, superglobals such as $_COOKIE became available in PHP 4.1.0. Cookie values also exist in $_REQUEST.


via <a href="http://us.php.net/setcookie" rel="nofollow">Documentation</a>.

It might be that you can access it on the same page load.


When you set a cookie, its value will be send to the client together with the page. $_COOKIE (or $HTTP_COOKIE_VARS) contains the cookie information that was <strong>sent by the client together with the request</strong>. Since you just set the cookie, the client will only be able to send the information on the next request.

The <a href="http://php.net/manual/en/function.setcookie.php" rel="nofollow">manual puts it like this</a>:


Once the cookies have been set, they can be accessed <em>on the next page load</em> with the $_COOKIE or $HTTP_COOKIE_VARS arrays.

</blockquote> <hr />


It's still the same problem. If the name and password are that of the admin, you're just setting a cookie, which happens silently. Then, you're echoing the contents of the cookie that were sent with the request, which is probably empty, so it doesn't echo anything.

What you really shouldn't be doing is storing the admin name and password in a cookie. It's <strong>Bad™</strong>. Anyone with access to the machine could just look at the cookie to get sensitive login information. Furthermore, the information will be transmitted with every request, most likely in plain text, so any proxy or sniffer can pick up the login information as well. Either encrypt them before storing them in the cookie or use proper sessions.


  • Why would you merge $_GET and $_POST in PHP?
  • Are there any essential reasons to use isset() over @ in php
  • How to add extra text to the tag in Joomla
  • Visual Studio extension: Change the hint path of an assembly reference
  • JUnit testing package private class in Maven formatted project
  • HTML code to upload images
  • PHP: Calling a private method from within a class dying badly
  • It is possible use the same sql azure instance from two different cloud service of two different sub
  • In C what exactly happens if i use () to initialize a double dimension array instead of the {}?
  • What Makes These Two Array Adds Different?
  • Laravel: Getting Session ID oddly truncates when using foreach
  • Silverlight DependencyProperty.SetCurrentValue Equivalent
  • Loading .coffee files via a view in Rails
  • How to use JavaScript to determine whether a file exists in a directory?
  • Create DicomImage from scratch using Dcmtk
  • How do I access an unhandled exception in an MVC Error view?
  • Replace value with Factor in r data.table
  • Yii2: Config params vs. const/define
  • How to redirect a user to a different server and include HTTP basic authentication credentials?
  • Javascript Callbacks with Object constructor
  • Validaiting emails with Net.Mail MailAddress
  • Which linear programming package should I use for high numbers of constraints and “warm starts” [clo
  • Can a Chrome extension content script make an jQuery AJAX request for an html file that is itself a
  • Javascript + PHP Encryption with pidCrypt
  • Display Images one by one with next and previous functionality
  • Weird JavaScript statement, what does it mean?
  • Web-crawler for facebook in python
  • Jquery - Jquery Wysiwyg return html as a string
  • Apache 2.4 - remove | delete | uninstall
  • A cron job substitute?
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • Unit Testing MVC Web Application in Visual Studio and Problem with QTAgent
  • SQL merge duplicate rows and join values that are different
  • Benchmarking RAM performance - UWP and C#
  • How to CLICK on IE download dialog box i.e.(Open, Save, Save As…)
  • Change div Background jquery
  • Qt: Run a script BEFORE make
  • reshape alternating columns in less time and using less memory
  • Reading document lines to the user (python)
  • How to load view controller without button in storyboard?