Click to See Complete Forum and Search --> : sessions


confused again
03-03-2005, 08:44 PM
This is really aggaivating me, every script that i ever use, whether it be created me or proffessionally created and tested by someone else, has this problem. I have a piece of code on a blank page that works fine, but when i include my other files to display the page content, the code no longer works.

Take this for example: I have a script which contains a session through a cookie, and it makes it to where when you logout, you have to log back in to see the content that was displayed on a page. It works fine, you click logout and when you try to go back it displays the login form instead of the content of the page.

Now when i add this dreadfull code to the begining of the file:
<?php
include_once ("../layout.php");
include_once ("../tables/table1.php");
?>

And this to the end:
<?php
include_once ("../tables/table2.php");
?>

The script no longer funtions correctly. When i click the logout button, and then click back on the browser it now displays the logout form, and the content that isnt suppose to be displayed unless you login.


I also found something else that strikes me as really odd. If i take out those include scripts it works fine. Now with them taken out, if i were to leave a line break at the beggining of the file, even before <?php, it stops working in the same way it does if i add those include files...What's happening here?


EDIT:
Problem solved, thanks.

SpectreReturns
03-03-2005, 11:08 PM
Maybe try using "require" or "include"?

Nutter
03-04-2005, 05:00 AM
Are you setting the cookies or session variables after the includes? I don't think you can set a cookie once there is data written to the browser. So, once your header block is written, cookies are not accepted. Try doing your cookie / session stuff first and the includes afterwards.