SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot
    Join Date
    Jan 2005
    Location
    ble
    Posts
    118
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Warning: Cannot send cooke/cache limit << what??

    Warning: session_register(): Cannot send session cookie - headers already sent by (output started at login.php:9) on line 25

    Warning: session_register(): Cannot send session cache limiter - headers already sent (output started at login.php:9) on line 25


    Thats the error I get when I log into a script, you can still log it, and do all the normal stuff, its just that darn error!! Why is it there? This is my line 25-26:

    Code:
    		session_register('user');
    		session_register('pass');
    If someone was helpful, give them some 'rep'.

  2. #2
    SitePoint Wizard HarryR's Avatar
    Join Date
    Dec 2004
    Location
    London, UK
    Posts
    1,376
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,
    In general what this error means is that the output has already been started by the PHP script on line 9. Before the first byte is sent to the client, PHP sends all the headers it needs to, so once it's sent you no longer have an opportunity to start the session, add cookies or any other headers.

    I suggest you put session_start () at the top of your PHP script, so the session cookie will be sent to the client and you can add/update session variables from anywhere within the script.

    Hope this helps

  3. #3
    SitePoint Zealot
    Join Date
    Jan 2005
    Location
    ble
    Posts
    118
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks man! Whilst on this ''topic'' how can you prevent:

    Warning: Cannot modify header information - headers already sent by (output started at header.php:77) in poll_cookie.php on line 21

    For a poll.. do I add header_start() above the poll's include? :S

    Thanks man, thanks again.
    If someone was helpful, give them some 'rep'.

  4. #4
    SitePoint Zealot
    Join Date
    Jan 2005
    Location
    ble
    Posts
    118
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Gah, please help!! The above line, line 21 is:
    Code:
            setcookie($cookie_name, "1", $endtime);
    And the whole script is:

    Code:
    <?php
    $cookie_expire = 96; // hours
    
    $action = (isset($HTTP_GET_VARS['action'])) ? $HTTP_GET_VARS['action'] : '';
    $action = (isset($HTTP_POST_VARS['action'])) ? $HTTP_POST_VARS['action'] : $action;
    $poll_ident = (isset($HTTP_GET_VARS['poll_ident'])) ? $HTTP_GET_VARS['poll_ident'] : '';
    $poll_ident = (isset($HTTP_POST_VARS['poll_ident'])) ? $HTTP_POST_VARS['poll_ident'] : $poll_ident;
    
    if ($action=="vote" && (isset($HTTP_POST_VARS['option_id']) || isset($HTTP_GET_VARS['option_id']))) {
        $cookie_name = "AdvancedPoll".$poll_ident;
        if (!isset($HTTP_COOKIE_VARS[$cookie_name])) {
            $endtime = time()+3600*$cookie_expire;
            setcookie($cookie_name, "1", $endtime);
        }
    }
    ?>
    HELP. BUMP. Heh
    If someone was helpful, give them some 'rep'.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •