Jump to content


Photo

Cannot send session cookie - headers already sent by (url)


  • Please log in to reply
6 replies to this topic

#1 karstev

karstev
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 08 September 2006 - 10:35 PM

This is doing my head in,
I am using php 5.1.4, Appache Server 2.2.3 on windows xp(sp2), I am just trying to get a simple session going, I have no complicated stuff, definately no spaces before my <?php declare, definately no spaces after ?>
my snytax is as follows, when I run this I cannot see a value for the variable, my session directory produces a file containing

"views|i:1;".

<?php
session_start();
$_SESSION['views'] = 1;
echo "Pageviews = ". $_SESSION['views'];
?>
Im pretty sure my php.ini settings are correct as I have reinstalled, followed all the tutes
----------------------- session settings ---------------------------------------
session.auto_start - off
session.use_trans_sid - 0
session.use_only_cookies - off
session.use_cookies - on




#2 jefkin

jefkin
  • Members
  • PipPipPip
  • Advanced Member
  • 55 posts

Posted 08 September 2006 - 11:01 PM

session_start() sends header urls.

If any spaces, blank lines, or text is in the file before <?PHP then PHP already sent your headers prior to seeing the session_start() call.

Check out your file.

Jeff

#3 karstev

karstev
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 08 September 2006 - 11:08 PM

Thanks Jeff but I definately have no spaces, all I have in the file is what I posted, I have even tried putting it all on the same line just to make sure and I still get the error.


#4 jefkin

jefkin
  • Members
  • PipPipPip
  • Advanced Member
  • 55 posts

Posted 08 September 2006 - 11:17 PM

karstev,

A somewhat stretching -- posiblity is if you use Smarty or some other templating system,

Smarty has the ability to filter output, and may have added text prior to your <?PHP,

Unfortunately, I've only encountered that error when some text (not just spaces) was output before the session_start().

Depending on your platform, sometimes invisible characters could be 'hiding' out.

You might try the old standby, rebuilding the file from scratch, though you've probably already tried it  :-X

Sorry if that doesn't help.

Jeff

#5 karstev

karstev
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 08 September 2006 - 11:35 PM

As of now I am throwing away my templating system, that was the answer, cant believe it.
Thanks soooo much.
Karen

#6 jefkin

jefkin
  • Members
  • PipPipPip
  • Advanced Member
  • 55 posts

Posted 08 September 2006 - 11:40 PM

Karen,

I've kept my templating system (Smarty) on a very short leash for a long time,

and now that I know it fairly well, I've begun to play with it.

Smarty may not be the latest and greatest, but it's stable, and extensible, and
worst case you can just write straight php, and it doesn't get offended :)

Jeff

#7 karstev

karstev
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 09 September 2006 - 01:03 PM

I worked it, got rid of all references in C:/windows, removed the dlls from here also, made sure they were all in c:/php, made sure the path variable was set, restarted and whalla...




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users