No announcement yet.

Error : Unable to add cookies, header already sent.

  • Filter
  • Time
  • Show
Clear All
new posts

  • Error : Unable to add cookies, header already sent.

    I've created 1 custom page by referring to vBulletin API Basics topic posted by Psionic Vision.
    Here is topic url :
    I'm getting following error :
    Unable to add cookies, header already sent.
    File: /home2/aditya43/public_html/forums/test.php
    Line: 1
    My test.php file contains following code :
    error_reporting(E_ALL & ~E_NOTICE);
    define('NO_REGISTER_GLOBALS', 1);
    define('THIS_SCRIPT', 'adi');
    $globaltemplates = array('adi');
    $navbits = array();
    $navbits[$parent] = 'Aditya Test Page';
    $navbits = construct_navbits($navbits);
    eval('$navbar = "' . fetch_template('navbar') . '";');
    if (!$vbulletin->userinfo['userid'])
    eval('print_output("' . fetch_template('adi') . '");');
    My template "adi" under vbulletin contains following code :
    <html dir="$stylevar[textdirection]" lang="$stylevar[languagecode]">
    <if condition="$adiinitcond">
    tmp.php file contains :
    $testcond1="$a is bigger";
    $testcond2="$b is bigger";
    However if i login to vbulletin forum and then access test.php, it works perfect. But as a guest it gives me above error.
    I also wanna allow guests on test.php or at least it should print vbulletin error message.

    Here is what i've done so far to get rid of above error :
    1. Removed all whitespace etc.
    2. Tried "<?php" tag without closing php tag "?>"
    3. Tested after removing "include('aaa/tmp.php');" from test.php
    4. Removed all "echo", "print" etc. from tmp.php

    The possible cause of above error is i'm trying to send data or something to browser before vbulletin cookies. So i traced my entire code and found i'm not sending anything to browser before cookies (or am i?).

  • #2
    You should be posting this over at where they deal with custom coding.

    You should try giving no permission *before* you eval any templates (like your navbar).

    If you need further help, you should post this over at

    Please don't PM or VM me for support - I only help out in the threads.
    vBulletin Manual & vBulletin 4.0 Code Documentation (API)
    Want help modifying your vbulletin forum? Head on over to
    If I post CSS and you don't know where it goes, throw it into the additional.css template.

    W3Schools &lt;- awesome site for html/css help


    widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.