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

  • Home
  • SEARCH
  • 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 6212815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:35:04+00:00 2026-05-24T06:35:04+00:00

Hi :) This is very strange — I am making the call: setcookie(ApplicationUserRank, test,

  • 0

Hi 🙂 This is very strange — I am making the call:

setcookie("ApplicationUserRank", "test", mktime (0, 0, 0, 1, 1, time()+60*60*24*30));

And then, in another file, calling:

echo $_COOKIE["ApplicationUserRank"];

However, the echo is blank! I am not really sure what I am doing wrong here, anyone care to explain? 🙂

EDIT:
Following Richard’s suggestion, I ran the following code:

echo "COOKIE: " . $_COOKIE["ApplicationUserRank"];

Directly after setting the cookie. Still blank! Something seriously strange is happening.

EDIT to my EDIT:

Turns out, that re-runnign the code DOES display the cookie! I guess $_COOKIE does not load from setcookie commands. In fact now that I think about it, I read about that somewhere… Anyways, it would seem that the SAME web file is capable of reading these cookies… Just not any other cookies. (This all is of course after applying many fixes suggested below)

  • 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-05-24T06:35:05+00:00Added an answer on May 24, 2026 at 6:35 am

    Trusting Tarek’s answer, and taking into consideration what rlemon says, it might prove useful to try the functions ob_start() and ob_end_flush(). They are output buffer controlling functions.

    As an example:

    <?php
    // php starts collecting the buffer rather than just sending it all out.
    ob_start();
    
    if(!isset($_COOKIE["ApplicationUserRank"])) {
        // This should throw an error about headers already being sent or the cookie wouldn't be set, yet under these circumstances, this will work perfectly.
        echo "Cookie has been set.";
        setcookie("ApplicationUserRank", "new test", mktime (0, 0, 0, 1, 1, 9001));
    }
    else {
        echo "Cookie is set.";
    }
    
    // now it sends the buffer all at once.
    ob_end_flush();
    ?>
    

    ob_start() and ob_end_flush() are also necessary for implementing today’s fashions (like encryption) if you have no server-side support for it. Click here for further reading material.

    EDIT:

    After reading Gumbo’s comment and checking PHP mktime’s page. Considering 9001 is an invalid year for UNIX, mktime() would always return -1, thus deleting the cookie.
    A solution would be as follows:

    setcookie("ApplicationUserRank", "new test", time()+60*60*24*30); // This should set the expiration date within 30 days from current time.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

it is very strange, because this error doesn't happen all the time... I have
This is very strange. I have an XAML file that looks as follows... <Window
This is very strange. I've got a simple form. I have a file input
I find this very strange, must be something I'm doing wrong, but still... I'm
This problem is very strange and I'm hoping someone can help me. For the
This is a very strange problem, and I just hope that I can clearly
I've written this very simple function to replace a file extension using LINQ in
I have this very strange problem while compiling the project. MOC seems to be
I have this very strange issue with my MVC 2 project. Often times, I'll
i have this very simple download page to get an xml file. the script

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.