Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,152,755 members, 7,817,090 topics. Date: Saturday, 04 May 2024 at 04:35 AM

I'm Getting "Warning: Session_start() [function.session-start]" Error. Pls Help - Webmasters - Nairaland

Nairaland Forum / Science/Technology / Webmasters / I'm Getting "Warning: Session_start() [function.session-start]" Error. Pls Help (3093 Views)

500 Internal Server Error >>>>>> Pls Explain / I Keep Getting This Error::pls Help ::parse Error: Syntax Error, Unexpected '.', / Php Error. .Pls Help! (2) (3) (4)

(1) (Reply) (Go Down)

I'm Getting "Warning: Session_start() [function.session-start]" Error. Pls Help by Nobody: 11:51pm On Jul 20, 2014
Experienced webmasters in the house, please I need your help and advice. I uploaded an application in php and when I load it, I usually get this error:
"Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/afriport/public_html/apn101/admin/adminhome.php:1) in /home/afriport/public_html/apn101/admin/session.php on line 1"

Please note that this is not the first time I am running this application. I have sucessfully uploaded it in a different domain previously without issues. But after editing the mysql information and uploading it to another server/domain, this is the error message I am getting. What could have gone wrong?

This is the screenshot of the php script attached below

Re: I'm Getting "Warning: Session_start() [function.session-start]" Error. Pls Help by dignityonly: 12:16am On Jul 21, 2014
use ob_start(); on your first line.

<?PHP
ob_start();
session_start();

if(){

}else{

}

?>

NOTE: This not the best way to go about it, but it will suppress your error.

You can find other solutions here
http://stackoverflow.com/questions/8028957/how-to-fix-headers-already-sent-error-in-php

1 Like

Re: I'm Getting "Warning: Session_start() [function.session-start]" Error. Pls Help by Nobody: 12:29am On Jul 21, 2014
ob_start() is just a walkaround, but in most cases, call your PHP Scripts and Sessions before any HTML.

Although ob_start() should fix it.

But
<?php
ob_flush(); //ob_flush first to flush previous cache
ob_start(); //Start a new Buffer
session_start(); //call the session
?>
Re: I'm Getting "Warning: Session_start() [function.session-start]" Error. Pls Help by Nobody: 12:39am On Jul 21, 2014
Ok, thanks
Will give it a try
Re: I'm Getting "Warning: Session_start() [function.session-start]" Error. Pls Help by dignityonly: 12:41am On Jul 21, 2014
coolsix: ob_start() is just a walkaround, but in most cases, call your PHP Scripts and Sessions before any HTML.

Although ob_start() should fix it.

But
<?php
ob_flush(); //ob_flush first to flush previous cache
ob_start(); //Start a new Buffer
session_start(); //call the session
?>


For some reason, calling just flush or ob_flush or even both together did not get my output buffers flushed, and calling ob_end_flush by itself didn't work either but calling them all worked well. Here is my new output flushing function.

<?php
function flush_buffers(){
ob_end_flush();
ob_flush();
flush();
ob_start();
}
?>
http://php.net/manual/en/function.ob-flush.php
Re: I'm Getting "Warning: Session_start() [function.session-start]" Error. Pls Help by Nobody: 12:47am On Jul 21, 2014
The issue still seem to persist and this error appears only in the admin end. The user end do not have such error.
Re: I'm Getting "Warning: Session_start() [function.session-start]" Error. Pls Help by dhtml(m): 1:41am On Jul 21, 2014
@op, please make sure there is no hidden space before you op start
e.g. you can start like this just to be sure.
<?php session_start();?>
If all these dont work, then tire ti ba o ni yen (your village people don catch up with you) - just kidding.
You can come back for advice, i will give you another approach which has never failed me so far.
Re: I'm Getting "Warning: Session_start() [function.session-start]" Error. Pls Help by maekhel(m): 1:43am On Jul 21, 2014
make sure u are using session_start before any HTML request is sent
Re: I'm Getting "Warning: Session_start() [function.session-start]" Error. Pls Help by Nobody: 2:50am On Jul 21, 2014
Depending on your server PHP settings at php.ini , ob_start() is sometimes disabled so it looks like its not working.

Make use of ob_get_status();

Returns true; if enabled and false; if disabled. So if false; you may want to customize some php.ini in /usr/bin/php/php.ini you can use

ini_get('ob_start', 'On'); //Turns it on (Requires root- Safe Mode off)

or Manually edit .ini and turn it on.

-----------------------------------
If you cannot still use your session... after all these.... oga.


#Surulere tongue
Re: I'm Getting "Warning: Session_start() [function.session-start]" Error. Pls Help by Nobody: 2:51am On Jul 21, 2014
maekhel: make sure u are using session_start before any HTML request is sent

session_start() can be used after HTML as long as there is <?php ob_start(); ?> or <?php ob_flush(); ?> at the top of the script
Re: I'm Getting "Warning: Session_start() [function.session-start]" Error. Pls Help by dhtml(m): 6:21am On Jul 21, 2014
coolsix:

session_start() can be used after HTML as long as there is <?php ob_start(); ?> or <?php ob_flush(); ?> at the top of the script
True, i am suspecting that the op has an extra space before that ob_start.
Re: I'm Getting "Warning: Session_start() [function.session-start]" Error. Pls Help by Kingsonly: 8:53am On Jul 21, 2014
<?php
session_start();
if($_SESSION['myusername']==""wink{
header("location:index.php"wink;
}
if(!$_SESSION){
header("location:index.php"wink;
}
$usname=$_SESSION['myusername'];
?>
"location:index.php" is space conscious so all you need to do is remove any space close to the code and make sure its the first line on each page, that should do the trick or copy my code and replace with yours

(1) (Reply)

Download Free School Management Portal Php Script / Enjoy The New Mtn 5gb Cheat For #100 (valid 5 Month) / Escrow.com And Nigeria

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 16
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.