Přidat otázku mezi oblíbenéZasílat nové odpovědi e-mailemVyřešeno Opera mi přestala přijímat cookies z PHP skriptu na localhostu

Tak se mi to povedlo vyřešit tímto skriptem, který jsem našel na php.net:

function createCookie($name, $value='', $maxage=0, $path='', $domain='', $secure=false, $HTTPOnly=false) 
    { 
        $ob = ini_get('output_buffering'); 

        // Abort the method if headers have already been sent, except when output buffering has been enabled 
        if ( headers_sent() && (bool) $ob === false || strtolower($ob) == 'off' ) 
            return false; 

        if ( !empty($domain) ) 
        { 
            // Fix the domain to accept domains with and without 'www.'. 
            if ( strtolower( substr($domain, 0, 4) ) == 'www.' ) $domain = substr($domain, 4); 
            // Add the dot prefix to ensure compatibility with subdomains 
            if ( substr($domain, 0, 1) != '.' ) $domain = '.'.$domain; 

            // Remove port information. 
            $port = strpos($domain, ':'); 

            if ( $port !== false ) $domain = substr($domain, 0, $port); 
        } 

        // Prevent "headers already sent" error with utf8 support (BOM) 
        //if ( utf8_support ) header('Content-Type: text/html; charset=utf-8'); 

        header('Set-Cookie: '.rawurlencode($name).'='.rawurlencode($value) 
                                    .(empty($domain) ? '' : '; Domain='.$domain) 
                                    .(empty($maxage) ? '' : '; Max-Age='.$maxage) 
                                    .(empty($path) ? '' : '; Path='.$path) 
                                    .(!$secure ? '' : '; Secure') 
                                    .(!$HTTPOnly ? '' : '; HttpOnly'), false); 
        return true; 
    }
Snad se to bude někomu hodit ;-)

Reakce na odpověď

1 Zadajte svou přezdívku:
2 Napište svou odpověď:
3 Pokud chcete dostat ban, zadejte libovolný text:

Zpět do poradny