Page 1 of 2

PHP Session header problem

Posted: Wed Mar 02, 2005 2:41 am
by robster3uk
Hi All,
I am going out of my mind with this header session probelm. At the top of every page that deals with $_SESSION Variables i have the folowing included code:

<?
ob_start();
session_start();
header("Cache-control:private"); //IE 6 Fix

BUT...... when i try running my code on the server IE6 wont keep the $_SESSION variables stored from page to page. The only way i can get it to work in IE6 is by specifically going into the internet options and overriding cookie handling. I really dont want this to be the only option as i dont want to have to tell everybody to override there cookies to view my site. I have read all of the other forums about this probelm and doen all that has been advised to no avail.

I really need some PHP SESSION guru's to help me out.

Cheers
Rob

Posted: Wed Mar 02, 2005 2:44 am
by pleigh
why not remove ob_start() function?

Posted: Wed Mar 02, 2005 2:49 am
by robster3uk
If i do that i get this:
Warning: Cannot modify header information

using the buffer thing is all that stops that.

Posted: Wed Mar 02, 2005 2:56 am
by pleigh
try this, remove the ob_start and edit your php.ini file, turn the output_buffering = On.....according to some guys in the forum, generally there is no threat in turning it On...

Posted: Wed Mar 02, 2005 3:03 am
by robster3uk
I will pop home at lunch and make the changes. BUT that worked here I have some new found hope... :P

So to get this straight............ using the ob_start() is giving me the same problem as the ie6 problem did?

Posted: Wed Mar 02, 2005 3:05 am
by pleigh
i had that same problem a month ago i think, and i decided to make that change as advised... :lol:

Posted: Wed Mar 02, 2005 3:13 am
by anjanesh
Try giving :

Code: Select all

header('Cache-Control: no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0');

Posted: Wed Mar 02, 2005 3:32 am
by robster3uk
Thanks Pleigh i will give it a try

anjanesh, This is new............. I will try this aswell.............

This is great guys thanks, I will be back after lunch to let you know how things went.

Cheers
Rob

Posted: Wed Mar 02, 2005 6:48 am
by robster3uk
No, never worked........ It is still not storing the $_SESSION Variables from page to page. I have tried all suggestions.......... Anymore?

Posted: Wed Mar 02, 2005 8:18 am
by MattF
You could try doing:

Code: Select all

<?php
session_start();
flush();

Posted: Wed Mar 02, 2005 9:08 am
by robster3uk
ok i done that and i now get an error the next time i send a header("Location: blah blah) command.

Posted: Wed Mar 02, 2005 9:28 am
by robster3uk
is there no other way of redirecting php pages instead of using header(Location: blah blah)???

What exactly am i doing when i start the session?

Posted: Wed Mar 02, 2005 9:39 am
by robster3uk
OR is there another way of storeing variables for other pages to use. except from $_SESSION, $_GET or $_POST ??

Posted: Wed Mar 02, 2005 9:56 am
by anjanesh
robster3uk wrote:is there no other way of redirecting php pages instead of using header(Location: blah blah)???

Code: Select all

<meta http-equiv="Refresh" content="0;url=wherever.php">
If the browser does not automatically redirect you, then click 
<a href="wherever.php">here</a>

Posted: Wed Mar 02, 2005 10:01 am
by robster3uk
what about passing variables?

I am still stuck on the originl probelm. Session variables are not being stored from page to page.