Problems with session_start()

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
delpi767
Forum Newbie
Posts: 7
Joined: Wed Jul 21, 2010 11:46 am

Problems with session_start()

Post by delpi767 »

when my script executtes, I receive the following warning message

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /mirror/villagesconnection/residents/login.php:1) in /mirror/villagesconnection/residents/login.php on line 2

Here's the code in its entirety...

Code: Select all

<?php
session_start();


$_SESSION['loggedin'] = "FALSE";

if ($_COOKIE['vid'])
   $vid = $_COOKIE['vid'];
else
   $vid = "";
   
if ($_COOKIE['pwd'])
   $pwd = $_COOKIE['pwd'];
else
   $pwd = "";
   
?>
What am I missing?

Thanks, Mac
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Problems with session_start()

Post by AbraCadaver »

There is something output before session_start(), either some HTML or a blank line or even a space. If that is all of your code and you're not including that file from another, then there's got to be a space or blank line or something before the <?php.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
delpi767
Forum Newbie
Posts: 7
Joined: Wed Jul 21, 2010 11:46 am

Re: Problems with session_start()

Post by delpi767 »

Shawn,

Thanks very much for your response. Unfortunately, what you suggest does not seem to be the case.

I have checked, double checked, and even copied these two line from other scripts which work just fine

Code: Select all

<?php
session_start(); 
There are no spaces prior to <? and there is exactly one space between the php and session_start.
I have removed and re-inserted that space on the off chance that it could have represented some non-printing character.

I do agree that something is trying to send header information but I cant imagine what it could be.

Thanks,

Mac
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Problems with session_start()

Post by AbraCadaver »

If you are saving the file in UTF-8 format, then your editor may be saving a BOM (byte order mark) at the start of the file. Either change encoding or see if your editor has a setting to not include the BOM.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
delpi767
Forum Newbie
Posts: 7
Joined: Wed Jul 21, 2010 11:46 am

Re: Problems with session_start()

Post by delpi767 »

Thanks,

Expression Web 4 was indeed saving the fle with a byte order mark. All is now okay.

How that one file all of a sudden was saved in that format and the others weren't I have no clue, it had been working just file until I made some innocuous change yesterday

I've been using Dreamweaver for years and decided to try Expression. So far, I find Dreamweaver vastly superior but I'll keep plugging with Expression to give it a fair shake.

Mac
Post Reply