php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31390 Included page doesn't read cookies
Submitted: 2005-01-03 17:20 UTC Modified: 2005-01-08 18:07 UTC
From: ricardomestre at oninetspeed dot pt Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: Irrelevant OS: NT
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: ricardomestre at oninetspeed dot pt
New email:
PHP Version: OS:

 

 [2005-01-03 17:20 UTC] ricardomestre at oninetspeed dot pt
Description:
------------
Hello all, 
Im sorry if this thread is repeated or even if its not a bug, but i searched a lot and no one could help me...

Here's the situation, i am trying to do a print page, and instead of printing a page one by one, i thought it would be best to have all the pages in one.

My code its pretty complex and specific so i made two simple pages with similar sctructure to see what happens.

Reproduce code:
---------------
Page test.php

<?php
setcookie("loged","yes",time()+3600, '', '.domain.com'); ###this setcookie its just to save time when testing, but it doesnt affect the final result...
if($_COOKIE['loged'] == 'yes') {
        for($i = 1; $i <= 3; $i++) {
               include 'http://www.domain.com/database/code.php?page=1';
        }
}
?>


Page code.php

<?php
if($_COOKIE['loged'] == 'yes') {
print "You can see the code<br>";
} else {
print "You must login first<br>";
}
?>

Expected result:
----------------
I'd expect to see:

You can see the code
You can see the code
You can see the code

Because the cookie is set...

Actual result:
--------------
Page test.php
The cookie is set,
it checks it just to prove that its well set,
to include the page 3 times the 'for',
the include with full link because of the args.


Page code.php
Cookie test fails... $_COOKIE['loged'] returns nothing.

and so the final result is:

You must login first
You must login first
You must login first

final note: Accessing code.php directly works fine. With include doesn't... :/

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-01-03 21:11 UTC] derick@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.

.
 [2005-01-05 22:11 UTC] ricardomestre at oninetspeed dot pt
I dont want to be boring but... I am searching everywhere and noone can help me :S... i tried the chat.. forums etc....

The try many things but it doesnt work :S


Why doesnt it work? its pretty weird because i guess the code is well done...

I guess even if its small.. its a bug... because the language doesnt do what is supposed...
 [2005-01-05 22:30 UTC] derick@php.net
Read the common pitfals at:
http://php.net/set_cookie
 [2005-01-08 18:07 UTC] ricardomestre at oninetspeed dot pt
I just noticed that the included page doesnt read normal vars or even session vars.

for instance:

Page test.php
<?php
$sib = 'yes';
if($sib == 'yes') {
         for($i = 1; $i <= 3; $i++) {
                include 'http://www.pmexpresso.com/database/code.php?page=1';
         }
}
?>

Page code.php
<?php
if($sib == 'yes') {
print "You can see the code<br>";
} else {
print "You must login first<br>";
}
?>


the result is:
You must login first
You must login first
You must login first
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 09 14:01:33 2025 UTC