#25929 [Bgs]: cannot read cookies within included file

From: Date: Tue, 21 Oct 2003 20:05:13 +0000
Subject: #25929 [Bgs]: cannot read cookies within included file
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-49304@lists.php.net to get a copy of this message
ID: 25929 User updated by: joe at kybert dot com Reported By: joe at kybert dot com Status: Bogus Bug Type: Variables related Operating System: XP (debug server) PHP Version: 4.3.2 New Comment: Why not? The remote file is on the same server, and the cookie was set to be accessable to all files from that domain. If you dont include it this way, you cannot pass arguments to the included file, this doesnt work: include("{$_SERVER['DOCUMENT_ROOT']}/test/file2.php?myparam=hello"); joe # Previous Comments: ------------------------------------------------------------------------ [2003-10-21 15:17:06] sniper@php.net If you include REMOTE file, of course the cookie is not passed to it. ------------------------------------------------------------------------ [2003-10-20 19:59:26] joe at kybert dot com Description: ------------ Cookie is not readable across multiple files. I have 2 files, file 1 sets a cookie (refresh file after 1st exe so cookie is sent) it then includes file 2, which reads and displays the cookie. Both files are in the same folder on the server, which is <servername>/test/<filenames> . File 2 fails to read the cookie! Reproduce code: --------------- file1.php contains: <?php setcookie("test", "set_by_file_1", time()+3600, "/", $_SERVER['HTTP_HOST']); echo "file 1 cookies: "; print_r($_COOKIE); include("http://$SERVER_NAME/test/file2.php"); ?> file2.php contains: <?php echo "<br>file 2 cookies: "; print_r($_COOKIE); ?> Expected result: ---------------- file 1 cookies: Array ( [LastUser] => ujoe [test] => set_by_file_1 ) file 2 cookies: Array ( [LastUser] => ujoe [test] => set_by_file_1 ) Actual result: -------------- file 1 cookies: Array ( [LastUser] => ujoe [test] => set_by_file_1 ) file 2 cookies: Array ( ) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=25929&edit=1

« previous php.bugs (#49304) next »