Cookies problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
turulojko
Forum Newbie
Posts: 6
Joined: Fri Feb 22, 2008 6:45 am

Cookies problem

Post by turulojko »

The CMS i work on it use cookies...
When i use it local (on my PC) it works good, but when i upload it to web server not works (don't create cookies).

*The server works with cookies, i know because i've installed Wordpres, forum...
Any ideas? :|
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: Cookies problem

Post by Jonah Bron »

So, it works on you computer, then it doesn't on the internet? Are you viewing with the same browser? It might be that you have cookies turned off in the php.ini, and wordpress uses set_ini() to change that.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: Cookies problem

Post by RobertGonzalez »

Have you tried writing a simple mini-app to test if cookies are working outside your application?
turulojko
Forum Newbie
Posts: 6
Joined: Fri Feb 22, 2008 6:45 am

Re: Cookies problem

Post by turulojko »

I use:

if (isset($_COOKIE["test"]))

and now i change it to:
if (isset($HTTP_COOKIE_VARS["test"]))

now it works 8O
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: Cookies problem

Post by RobertGonzalez »

Dude, what version of PHP are you using? Sound like you have register_long_arrays on, but that shouldn't affect short super global arrays.

Run the following in a new file and tell us the results please.

Code: Select all

<?php
 
$neg = array('off', 0, false, '', null);
$flags = array(
    'Register Globals' => 'register_globals',
    'Short Tags' => 'short_open_tag',
    'Display Errors' => 'display_errors',
    'Magic Quotes GPC' => 'magic_quotes_gpc',
    'Magic Quotes Runtime' => 'magic_quotes_runtime',
    'Magic Quotes Sybase' => 'magic_quotes_sybase',
);
$ve = phpversion();
$os = PHP_OS;
$er = intval(error_reporting());
foreach ($flags as $n => $v)
{
    $flags[$n] = (in_array(strtolower(ini_get($v)), $neg) ? 'Off' : 'On');
}
$flags['Config file'] = get_cfg_var('cfg_file_path');
if (empty($flags['Config file']))
{
    $flags['Config file'] = '-';
}
$cli = (php_sapi_name() == 'cli');
$eol = "\n";
 
$gle = get_loaded_extensions();
$rows = array();
$le = '';
$wide = 4;
$j = count($gle);
$pad = $wide - $j % $wide;
$len = max(array_map('strlen', $gle));
$func = create_function('$a', 'return str_pad($a, ' . intval($len) . ');');
$gle = array_map($func, $gle);
for($i = 0; $i < $j; $i += $wide)
{
    $le .= '   ' . implode('   ', array_slice($gle, $i, $wide)) . $eol;
}
 
$ec = array(
    'E_STRICT' => 2048, 'E_ALL' => 2047, 'E_USER_NOTICE' => 1024,
    'E_USER_WARNING' => 512, 'E_USER_ERROR' => 256, 'E_COMPILE_WARNING' => 128,
    'E_COMPILE_ERROR' => 64, 'E_CORE_WARNING' => 32, 'E_CORE_ERROR' => 16,
    'E_NOTICE' => 8, 'E_PARSE' => 4, 'E_WARNING' => 2, 'E_ERROR' => 1,
);
 
$e = array();
$t = $er;
foreach ($ec as $n => $v)
{
    if (($t & $v) == $v)
    {
        $e[] = $n;
        $t ^= $v;
    }
}
if (ceil(count($ec) / 2) + 1 < count($e))
{
    $e2 = array();
    foreach ($ec as $n => $v)
    {
        if (!in_array($n, $e) and $n != 'E_ALL')
        {
            $e2[] = $n;
        }
    }
    $er = $er . ' ((E_ALL | E_STRICT) ^ ' . implode(' ^ ', $e2) . '))';
}
else
{
    $er = $er . ' (' . implode(' | ', $e) . ')';
}
 
if (!$cli)
{
    echo '<html><head><title>quick info</title></head><body><pre>', $eol;
}
 
echo 'PHP Version: ', $ve, $eol;
echo 'PHP OS: ', $os, $eol;
echo 'Error Reporting: ', $er, $eol;
foreach ($flags as $n => $v)
{
    echo $n, ': ', $v, $eol;
}
echo 'Loaded Extensions:', $eol, $le, $eol;
 
if (!$cli)
{
    echo '</pre></body></html>', $eol;
}
 
?>
turulojko
Forum Newbie
Posts: 6
Joined: Fri Feb 22, 2008 6:45 am

Re: Cookies problem

Post by turulojko »

PHP Version: 4.4.7
PHP OS: Linux
Error Reporting: 2039 ((E_ALL | E_STRICT) ^ E_STRICT ^ E_NOTICE))
Register Globals: Off
Short Tags: On
Display Errors: On
Magic Quotes GPC: On
Magic Quotes Runtime: Off
Magic Quotes Sybase: Off
Config file: /usr/local/Zend/etc/php.ini
Loaded Extensions:
xmlrpc xml wddx tokenizer
standard sockets session pspell
posix overload mysql mhash
mcrypt mbstring imap iconv
gettext gd ftp domxml
curl ctype calendar bcmath
zlib pcre openssl ionCube Loader
Zend Optimizer
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: Cookies problem

Post by RobertGonzalez »

It seems that your installation might have long arrays being read only. I am not even sure how to do that in PHP4.
Post Reply