PHP Session header problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
robster3uk
Forum Newbie
Posts: 10
Joined: Wed Mar 02, 2005 2:26 am

PHP Session header problem

Post 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
User avatar
pleigh
Forum Contributor
Posts: 445
Joined: Wed Jan 19, 2005 4:26 am

Post by pleigh »

why not remove ob_start() function?
User avatar
robster3uk
Forum Newbie
Posts: 10
Joined: Wed Mar 02, 2005 2:26 am

Post by robster3uk »

If i do that i get this:
Warning: Cannot modify header information

using the buffer thing is all that stops that.
User avatar
pleigh
Forum Contributor
Posts: 445
Joined: Wed Jan 19, 2005 4:26 am

Post 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...
User avatar
robster3uk
Forum Newbie
Posts: 10
Joined: Wed Mar 02, 2005 2:26 am

Post 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?
User avatar
pleigh
Forum Contributor
Posts: 445
Joined: Wed Jan 19, 2005 4:26 am

Post by pleigh »

i had that same problem a month ago i think, and i decided to make that change as advised... :lol:
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post 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');
User avatar
robster3uk
Forum Newbie
Posts: 10
Joined: Wed Mar 02, 2005 2:26 am

Post 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
User avatar
robster3uk
Forum Newbie
Posts: 10
Joined: Wed Mar 02, 2005 2:26 am

Post by robster3uk »

No, never worked........ It is still not storing the $_SESSION Variables from page to page. I have tried all suggestions.......... Anymore?
MattF
Forum Contributor
Posts: 225
Joined: Sun May 19, 2002 9:58 am
Location: Sussex, UK

Post by MattF »

You could try doing:

Code: Select all

<?php
session_start();
flush();
User avatar
robster3uk
Forum Newbie
Posts: 10
Joined: Wed Mar 02, 2005 2:26 am

Post by robster3uk »

ok i done that and i now get an error the next time i send a header("Location: blah blah) command.
User avatar
robster3uk
Forum Newbie
Posts: 10
Joined: Wed Mar 02, 2005 2:26 am

Post 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?
User avatar
robster3uk
Forum Newbie
Posts: 10
Joined: Wed Mar 02, 2005 2:26 am

Post by robster3uk »

OR is there another way of storeing variables for other pages to use. except from $_SESSION, $_GET or $_POST ??
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post 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>
User avatar
robster3uk
Forum Newbie
Posts: 10
Joined: Wed Mar 02, 2005 2:26 am

Post by robster3uk »

what about passing variables?

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