Why I got two defferent values of $_COOKIE on the same page?
Posted: Thu Apr 29, 2010 4:51 am
Hi,
I get a strange problem:
I set a Cookie when I logined(such as : setcookie(‘CustomField1’,'xx zz dd ',2545063036);),then turn to main page。There is a area filled by using AJAX in the main page。In the main page and the AJAX area,all use print_r($_COOKIE);
The result of the main page is :
Array ( [AJSTAT_ok_times] => 11 [PHPSESSID] => 7c9d3f4120455baf58e0293e28a05a80 )
The result of the AJAX area in the main page is :
Array ( [CustomField1] => a19YQEtoVFZHTVNcX0JObWQay3tJylusPAiYJmQEY5VQoWGj9eC0RPO11bQ09vXThcV0RIPF1ZQUg [AJSTAT_ok_times] => 11 [PHPSESSID] => 7c9d3f4120455baf58e0293e28a05a80 )
The result of the AJAX area is right。Why the main page does get another values?
The URL of the main page is http://localhost:8078/main/default (Call the form of /main/default )
The URL of the AJAX area http://localhost:8078/main/default/Ajax/Sub/index (Call the form of /main/default/Ajax/Sub/index)
using Php5.2, the setting about Session and Cookie in the php.ini is following:
[Session]
session.save_handler = files
session.save_path = c:\webroot\tmp
session.use_cookies = 1
session.name = PHPSESSID
session.auto_start = 1
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain =
session.cookie_httponly =
session.serialize_handler = php
session.gc_probability = 1
session.gc_divisor = 100
session.gc_maxlifetime = 36000
session.bug_compat_42 = 0
session.bug_compat_warn = 1
session.referer_check =
session.entropy_length = 0
session.entropy_file =
session.cache_limiter = nocache
session.cache_expire = 180
session.use_trans_sid = 0
url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"
The Setting in Apache is following,using URL Rewrite
<VirtualHost *:8078>
ServerName "localhost"
DocumentRoot "c:/WebRoot"
<Directory "/WebRoot">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
Alias /htm "/WebRoot/htm/index.php"
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^/htm/?$ /htm/$1
</IfModule>
Alias /main "/WebRoot/main/index.php"
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^/main/?$ /main/$1
</IfModule>
</VirtualHost>
I get a strange problem:
I set a Cookie when I logined(such as : setcookie(‘CustomField1’,'xx zz dd ',2545063036);),then turn to main page。There is a area filled by using AJAX in the main page。In the main page and the AJAX area,all use print_r($_COOKIE);
The result of the main page is :
Array ( [AJSTAT_ok_times] => 11 [PHPSESSID] => 7c9d3f4120455baf58e0293e28a05a80 )
The result of the AJAX area in the main page is :
Array ( [CustomField1] => a19YQEtoVFZHTVNcX0JObWQay3tJylusPAiYJmQEY5VQoWGj9eC0RPO11bQ09vXThcV0RIPF1ZQUg [AJSTAT_ok_times] => 11 [PHPSESSID] => 7c9d3f4120455baf58e0293e28a05a80 )
The result of the AJAX area is right。Why the main page does get another values?
The URL of the main page is http://localhost:8078/main/default (Call the form of /main/default )
The URL of the AJAX area http://localhost:8078/main/default/Ajax/Sub/index (Call the form of /main/default/Ajax/Sub/index)
using Php5.2, the setting about Session and Cookie in the php.ini is following:
[Session]
session.save_handler = files
session.save_path = c:\webroot\tmp
session.use_cookies = 1
session.name = PHPSESSID
session.auto_start = 1
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain =
session.cookie_httponly =
session.serialize_handler = php
session.gc_probability = 1
session.gc_divisor = 100
session.gc_maxlifetime = 36000
session.bug_compat_42 = 0
session.bug_compat_warn = 1
session.referer_check =
session.entropy_length = 0
session.entropy_file =
session.cache_limiter = nocache
session.cache_expire = 180
session.use_trans_sid = 0
url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"
The Setting in Apache is following,using URL Rewrite
<VirtualHost *:8078>
ServerName "localhost"
DocumentRoot "c:/WebRoot"
<Directory "/WebRoot">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
Alias /htm "/WebRoot/htm/index.php"
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^/htm/?$ /htm/$1
</IfModule>
Alias /main "/WebRoot/main/index.php"
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^/main/?$ /main/$1
</IfModule>
</VirtualHost>