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 8620145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:30:51+00:00 2026-06-12T06:30:51+00:00

At first I had my setcookie() as: $school = Some Value; setcookie(default_school, $school, time()+3600);

  • 0

At first I had my setcookie() as:

$school = "Some Value";
setcookie("default_school", $school, time()+3600);
var_dump($_COOKIE);

That didn’t work, so I did some searching, and found that I probably just needed to set a path, so I changed it to:

$school = "Some Value";
setcookie("default_school", $school, time()+3600, "/", ".mydomain.com");
var_dump($_COOKIE);

That still didn’t work so I did some more investigating, and determined that my issue must just me setting the cookie too late. So I then started checking my if my headers were set in certain parts of my code, which needs to return bool(false).

var_dump(headers_sent());

First the top of my index.php, then at the top of my header.php, but still the same result; they both return true?

I feel like this should be so simple, and I’m getting nowhere. A push in the right direction would be highly appreciated.

Thanks,
Isaac

EDIT: Just tried putting it before the init hook, and it returned false. I then put the setcookie function there, and still no luck.

EDIT 2: Ended up adding:

function set_user_cookie() {
    $school = "Some Value";
    setcookie('default_school', $school, time()+3600);
}

add_action('init', 'set_user_cookie');

and now it works perfectly.

  • 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-12T06:30:52+00:00Added an answer on June 12, 2026 at 6:30 am

    To debug this kind of situation, you should start with enabling proper error reporting (don’t use in a production environment):

    error_reporting(-1);
    ini_set('display_errors', 'On');
    

    If you subsequently call setcookie() it will issue a warning that will tell you where the output has started.

    If you can’t do that, you can use headers_sent() in this manner to figure out where the output has started as well:

    if (headers_sent($file, $line)) {
        echo "Output started in $file on line $line\n";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently had my app certified (first time!) but not automatically published. The game
First time trying to deal with users logging in with ASP.net and haven't had
At first I had this (work in wamp but not in my web server)
I first had to follow the instructions here to make sure that I had
In my application i have two drop down boxes first box had origin second
I've got a UITableView with custom tablecells. First I had a version which implemented
I am creating a WCF service. At first I had one WCF service library
I have a problem with this script. At first I had the <div> s
In one of my first activity i had a small portion of mapview and
I had an idea for my first mobile application and I was thinking of

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.