zero-perfoliate
zero-perfoliate

Author Topic: session_start Warnings  (Read 1133 times)

Offline R4nk3d

  • PHP Workers
  • **
  • Posts: 8
  • Karma: +0/-0
session_start Warnings
« on: July 25, 2008, 11:29:38 PM »
Code: [Select]
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at #####) in ##### on line 3

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at #####) in ##### on line 3
Im getting these warnings on my webpage while im using this code for my session:
Code: [Select]
<?php //Line 2
session_start(); //Line 3
$_SESSION['name'] = $_GET['name']; //Line 4
?>
//Line 5
How can i fix this? Im making it so when u go to the index, javascript makes u insert ur name, then ur redirected to welcome.php?name=YourNameHere and it starts the session so i can keep track of what person views what. Thanks in advance.

icestormz

  • Guest
Re: session_start Warnings
« Reply #1 on: July 26, 2008, 09:42:22 AM »
basically your getting this error because you have a session_start(); after any html coding so it causes that error.

solution:

Put this above all html coding, best to put it  on line 1 of the page php page

Code: [Select]
<?php
session_start();
$_SESSION['name'] = $_GET['name'];
?>

let me know if this works out for you if not please attach the file to your next post

Offline R4nk3d

  • PHP Workers
  • **
  • Posts: 8
  • Karma: +0/-0
Re: session_start Warnings
« Reply #2 on: July 26, 2008, 11:32:53 AM »
thanks, i got it right after i posted but for some reason it didnt delete the topic XD

icestormz

  • Guest
Re: session_start Warnings
« Reply #3 on: July 26, 2008, 12:13:04 PM »
:) no problem glad to help

Offline KevInKauai

  • New PHP Members
  • Posts: 2
  • Karma: +0/-0
Re: session_start Warnings
« Reply #4 on: August 26, 2009, 05:06:20 AM »
Alohas!

I'm a PHP newbie and I'm trying to enhance an existing PHP site with some needed mobile alternatives. I found what looks like a good mobile testing solution. (It's the one which ends with
   "if ($mobile_browser>0 {
       // do something
    }
    else {
       // do something else"

The existing PHP began with

    session_start();
    $_SESSION['ok'] = true;

so I left those two lines above the additional test.

I'm getting the same "session caceh limiter" as in the original post of this (older) thread.

ANY HINTS greatly appreciated.

mahalo ... KevInKauai

Offline icestormz

  • Administrator
  • PHP Help Guru's
  • *****
  • Posts: 73
  • Karma: +0/-0
Re: session_start Warnings
« Reply #5 on: August 28, 2009, 11:42:40 AM »
it would help if you show me the script and the actual error because the error tells you which line to look at