NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page What's wrong with session_start()?

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 07-01-2005, 07:54 AM THREAD STARTER               #1 (permalink)
Senior Member
 
Porte's Avatar
Join Date: May 2005
Location: I'm right here
Posts: 3,526
Porte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud of
 



What's wrong with session_start()?


Hello,
????: NamePros.com http://www.namepros.com/programming/103289-whats-wrong-with-session_start.html

This is the code :

<? session_start(); ?>

When I access this page it gives :

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /mnt/storage/users/c/u/s/customcoding/index.php:1) in /mnt/storage/users/c/u/s/customcoding/index.php on line 1

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /mnt/storage/users/c/u/s/customcoding/index.php:1) in /mnt/storage/users/c/u/s/customcoding/index.php on line 1


To tell you the truth, I'm amazed with the results

How can I avoid this ugly error?

I believe I shouldn't see it...
Porte is offline  
Old 07-01-2005, 08:36 AM   #2 (permalink)
Senior Member
 
-Ray-'s Avatar
Join Date: Jun 2005
Location: Pennsylvania
Posts: 1,839
-Ray- has much to be proud of-Ray- has much to be proud of-Ray- has much to be proud of-Ray- has much to be proud of-Ray- has much to be proud of-Ray- has much to be proud of-Ray- has much to be proud of-Ray- has much to be proud of-Ray- has much to be proud of
 



Output buffering is turned off. Contact your webhost and ask him to turn it off.

Or you can use the ob_start (); command which will buffer the headers for you.

Your Best Friend
-------------------------
http://us4.php.net/ob_start
__________________
Poker News, articles, discussion
LIKE THIS

Its an iPod, a phone, and an internet communications device.
-Ray- is offline  
Old 07-01-2005, 08:45 AM THREAD STARTER               #3 (permalink)
Senior Member
 
Porte's Avatar
Join Date: May 2005
Location: I'm right here
Posts: 3,526
Porte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud of
 



Hello, can you direct me into using ob_start() correctly, I just never used the ob functions. Can you give me a sample code?

I tried to put ob_start() above session_start() but nothing.

I do not know if this is a resolution to my current host or not.. I just added
error_reporting(0);
before
session_start();

Correct me please.
Porte is offline  
Old 07-01-2005, 09:08 AM   #4 (permalink)
Senior Member
 
-Ray-'s Avatar
Join Date: Jun 2005
Location: Pennsylvania
Posts: 1,839
-Ray- has much to be proud of-Ray- has much to be proud of-Ray- has much to be proud of-Ray- has much to be proud of-Ray- has much to be proud of-Ray- has much to be proud of-Ray- has much to be proud of-Ray- has much to be proud of-Ray- has much to be proud of
 



Put ob_start() start above the session_start()

after ob_start(); use ob_getcontents(); (i think)

after that use ob_printcontents(); (think again)

then ob_end()

i think they are the right ones, the content ones, check in that outpout buffering link i gave you
__________________
Poker News, articles, discussion
LIKE THIS

Its an iPod, a phone, and an internet communications device.
-Ray- is offline  
Old 07-01-2005, 09:15 AM THREAD STARTER               #5 (permalink)
Senior Member
 
Porte's Avatar
Join Date: May 2005
Location: I'm right here
Posts: 3,526
Porte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud of
 



let me check, thanks!

Doesn't work now when I try to use header somewhere it says

Warning: Cannot modify header information - headers already sent by (output started at /home/designpo/public_html/index.php:1) in /home/designpo/public_html/includes/account_info.php on line 6
Porte is offline  
Old 07-01-2005, 11:46 AM   #6 (permalink)
Senior Member
 
-Ray-'s Avatar
Join Date: Jun 2005
Location: Pennsylvania
Posts: 1,839
-Ray- has much to be proud of-Ray- has much to be proud of-Ray- has much to be proud of-Ray- has much to be proud of-Ray- has much to be proud of-Ray- has much to be proud of-Ray- has much to be proud of-Ray- has much to be proud of-Ray- has much to be proud of
 



then u reuse the ob start command..

The easiest thing to do is contact your web host and ask him to turn on php output buffering.

If u need a host that has it on. read my sig!
__________________
Poker News, articles, discussion
LIKE THIS

Its an iPod, a phone, and an internet communications device.
-Ray- is offline  
Old 07-01-2005, 11:52 AM THREAD STARTER               #7 (permalink)
Senior Member
 
Porte's Avatar
Join Date: May 2005
Location: I'm right here
Posts: 3,526
Porte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud of
 



If you accept credit cards globally, I could sign up..otherwise, no pp support
Porte is offline  
Old 07-01-2005, 12:33 PM   #8 (permalink)
Senior Member
 
-Ray-'s Avatar
Join Date: Jun 2005
Location: Pennsylvania
Posts: 1,839
-Ray- has much to be proud of-Ray- has much to be proud of-Ray- has much to be proud of-Ray- has much to be proud of-Ray- has much to be proud of-Ray- has much to be proud of-Ray- has much to be proud of-Ray- has much to be proud of-Ray- has much to be proud of
 



check ur pms
__________________
Poker News, articles, discussion
LIKE THIS

Its an iPod, a phone, and an internet communications device.
-Ray- is offline  
Old 07-02-2005, 12:30 AM   #9 (permalink)
New Member
Join Date: Jul 2005
Posts: 8
val539 is an unknown quantity at this point
 



PHP Code:
<? @session_start(); ?>
or for more security script:

PHP Code:
<? ignore_user_abort(1); error_reporting(0);  session_start(); ?>
Regards
val539 is offline  
Old 07-02-2005, 03:36 AM   #10 (permalink)
Pro Coder & Designer
 
aween's Avatar
Join Date: Apr 2005
Location: Netherlands
Posts: 967
aween is just really niceaween is just really niceaween is just really niceaween is just really niceaween is just really niceaween is just really niceaween is just really niceaween is just really nice
 



i think this has been fixed . he found a good host now i guess
__________________
aween web development
aween is offline  
Old 07-02-2005, 05:30 AM   #11 (permalink)
NamePros Expert
 
Peter's Avatar
Join Date: Nov 2003
Location: Scotland
Posts: 5,069
Peter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond repute
 


Child Abuse Save The Children Save The Children Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009
in my opinion using output buffering certainly is not the best solution, he would be best finding what is causing the error in the first place.
Peter is offline  
Old 07-02-2005, 06:53 AM THREAD STARTER               #12 (permalink)
Senior Member
 
Porte's Avatar
Join Date: May 2005
Location: I'm right here
Posts: 3,526
Porte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud of
 



Yea, it's been fixed now as xlusive said.. it was something with the host, that output buffering is Off, which globally turns off all session_start() usage.

Thanks though;
Ahmed
Porte is offline  
Old 07-02-2005, 10:41 AM   #13 (permalink)
NamePros Expert
 
Peter's Avatar
Join Date: Nov 2003
Location: Scotland
Posts: 5,069
Peter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond repute
 


Child Abuse Save The Children Save The Children Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009
as far as I am aware output buffering has nothing to do with sessions (and nothing is mentioned in the php manual). The reason the script failed in the first place was because the script output to the browser BEFORE session was started (even a space output causes this error).

The way you have fixed the problem is just a quick and dirty way to go about it and not actually fixing the problem itself.
Peter is offline  
Old 07-02-2005, 11:22 AM THREAD STARTER               #14 (permalink)
Senior Member
 
Porte's Avatar
Join Date: May 2005
Location: I'm right here
Posts: 3,526
Porte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud ofPorte has much to be proud of
 



Ok it's a dirty way, and I like it.. anymore comments?
__________________
WP Theme Developer
Your One-stop for Premium Magazine/CMS WordPress Themes
Deluxe Themes
Porte is offline  
Old 07-02-2005, 06:39 PM   #15 (permalink)
NamePros Expert
 
Peter's Avatar
Join Date: Nov 2003
Location: Scotland
Posts: 5,069
Peter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond repute
 


Child Abuse Save The Children Save The Children Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009
just offering advise thats all, that is what you asked for
Peter is offline  
Old 07-08-2005, 10:02 PM   #16 (permalink)
NamePros Member
Join Date: Oct 2003
Posts: 126
i386 is an unknown quantity at this point
 



If you used this code, then it'll error out:

<html>
BLAH...
<?php
session_start();
?>

What I use:

Code:
<?php
session_start();

echo <<<ENDDOC
MY DOCUMENT HERE
ENDDOC;

?>
i386 is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Meta-tags wrong? FastIcon.com Marketing Techniques 5 10-27-2004 12:43 PM
Push to Wrong Account... What can be done? Jeanco Domain Name Discussion 7 12-28-2003 07:43 AM

Liquid Web Smart Servers  
All times are GMT -7. The time now is 06:04 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger