Sessions, cookie header conflicts

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

Post Reply
User avatar
harsha
Forum Contributor
Posts: 103
Joined: Thu Jul 11, 2002 1:35 am
Location: Bengaluru (Bangalore) > Karnataka > India

Sessions, cookie header conflicts

Post by harsha »

i am using sessions to store the name of the skin for my site the code is some thing like this

session_start();

if(!session_register($_SESSION['Skin'])){
$_SESSION['Skin'] = "Default";
}

and i am using the value of the $_SESSION to include the index.php of the skin folder

include("Skinz/".$_SESSION['Skin']."/index.php");

when i run the script i am getting a waring the
session cookie cannot be balh balh... header already sent

how do i eliminate this warning using ob_start() and related fuction
or is there any possibilty of eliminating this warining with out using ob_start
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

Read this:

viewtopic.php?t=1157

Mark
User avatar
Dr Evil
Forum Contributor
Posts: 184
Joined: Wed Jan 14, 2004 9:56 am
Location: Switzerland

Post by Dr Evil »

Your error is possibly comming from the fact that you sent some info to the browser before your session_start().
Make sure you have no blank lines outside of php tags.

Dr Evil
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

as both previous posts stated there cannot be any output to the browser before the script sends its headers

also, whitespace is not allowed
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Once you've fixed the header problem you should change:

Code: Select all

if(!session_register($_SESSION['Skin'])){
to

Code: Select all

if (!isset($_SESSION['Skin'])) {
Mac
User avatar
harsha
Forum Contributor
Posts: 103
Joined: Thu Jul 11, 2002 1:35 am
Location: Bengaluru (Bangalore) > Karnataka > India

thanx fixed the session problem

Post by harsha »

thank you all it was due to the whitespaces
Wow this is a silly mistake !!!!
Post Reply