Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7963547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T05:37:56+00:00 2026-06-04T05:37:56+00:00

<?php setcookie(name, abc); echo $_COOKIE[name]; ?> When I reload this page, it shows nothing

  • 0
<?php
    setcookie("name", "abc");
    echo $_COOKIE["name"];
?>

When I reload this page, it shows nothing on the screen. Why?

But reload again, abc is shown.

WHY??

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T05:37:58+00:00Added an answer on June 4, 2026 at 5:37 am

    When you set a cookie, it is not available until the next page load.

    This is very clearly laid out in the documentation, which you should read.

    Once the cookies have been set, they can be accessed on the next page load 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.

    and

    Cookies will not become visible until the next loading of a page that the cookie should be visible for. To test if a cookie was successfully set, check for the cookie on a next loading page before the cookie expires. Expire time is set via the expire parameter. A nice way to debug the existence of cookies is by simply calling print_r($_COOKIE);.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason This php script won't echo anything: <?php setcookie(pop,'hi',time()+604800); echo $HTTP_COOKIE_VARS['pop']; ?>
I would like to do the following in php : setcookie('name', $value, $Cookie_Expiration,'/'); then
Here is the web structure of my page: 01.<?php // rnlogout.php 02.include_once 'rnheader.php'; 03.echo
Got it from php.net, but I am not sure is this how everybody destroy
index.php session_start(); if(!isset($_GET['n'])) { $_SESSION['foo'] = bar; header(Location: /index.php?n=D); } echo FOO: .$_SESSION['foo']; This
I save a cookie in PHP: setcookie('name['.time().']','Andres',time()+86400,'/'); As you can see, it is not
I have this function in my PHP : setcookie(UserPusser, $user, time() + 604800, /pusser/beta/);
I am new to PHP, I practised PHP setcookie() just now and failed. http://localhost/test/
PHP uses magic quotes by default but has gotten a lot of flak for
I have set my cookie in PHP using the following: setcookie(id, 100, time()+100000, /AP,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.