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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:05:24+00:00 2026-05-16T11:05:24+00:00

The relevant peice of code is below. According to php.net I have to make

  • 0

The relevant peice of code is below. According to php.net I have to make sure there is no output, not even any whitespace. There isn’t any. the php tag is the very first tag in the document no whitespace preceding it. What am I doing wrong?

<?php

    // main.php
    // 6:48 PM 8/6/2010

    include('config.php');

    // Does myid cookie exist?
    if ( !isset( $_COOKIE['myid'] ) )
    {
        // Generate myid
        $myid = substr(md5(date( 'Ymdhis' ) . str_replace( '.', '', $_SERVER['REMOTE_ADDR'] ) ), 0, 10);

        // set the cookie
        setcookie( 'myid', $myid, time() + 31536000 );
  • 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-16T11:05:25+00:00Added an answer on May 16, 2026 at 11:05 am

    There needs to be no output at all before calling setcookie, even from other scripts.

    If config.php had whitespace before the opening <?php tag (or after the closing ?>), for example, that would cause the problem.

    Hunt down where header is called or some text outside of PHP tags (even whitespace) exists. That’s what’s happening, no doubt.

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

Sidebar

Related Questions

Not really a programming question, but relevant to many programmers... Let's say I have
We have a piece of code which saves a .Net System.Drawing.Bitmap to file. The
Is PHP still a relevant language in 2017?
Just looking for the relevant documentation. An example is not necessary, but would be
When I need some complex algorithm I first check if there's anything relevant already
I have two tables (well, two relevant for this question) : Bets (holds the
I have an XML document that I'm trying to style via CSS. A relevant
I have a piece of code: EDIT: The _penParams are initialized as the added
My question is quite relevant to something asked before but I need some practical
Ok, i've read most relevant questions asked here previously on this but I still

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.