session error

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

nainil
New php-forum User
New php-forum User
Posts: 4
Joined: Sun Mar 16, 2003 9:03 pm
Location: India
Contact:

session error

Postby nainil » Tue Apr 01, 2003 10:42 am

Hi everybody,

Please, could you help me to find out why I'm getting an error message like one below.

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at file1.php:2) in InitSession.php on line 2.

It was working fine few days ago.

Thank you,

Best Regards,
Nainil Chheda.
Founder, Proprietor
eLiteral - A Web Hosting Co.
----------------------------
http://services.eliteral.com/
http://order.eliteral.com/
http://domains.eliteral.com/
----------------------------

User avatar
Redcircle
Moderator
Moderator
Posts: 830
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA
Contact:

Postby Redcircle » Wed Apr 02, 2003 5:21 pm

something is being sent to the browser before the session cookie is created.

Make sure there are no spaces before the first <?php

Osaou
New php-forum User
New php-forum User
Posts: 7
Joined: Tue Apr 15, 2003 4:52 pm
Location: Stockholm, Sweden
Contact:

Postby Osaou » Tue Apr 15, 2003 5:09 pm

Or, take use of this nifty function:

Code: Select all

ob_start();

It prevents the compiler to flush (send it to the user) parsed info directly...
This way it's only sent when the buffer reaches its limit, at the end of the page, or when you command it to... =)
Meaning you can use functions such as session_start() or header() when html-material already has been sent...

/Osaou


Return to “PHP coding => General”

Who is online

Users browsing this forum: No registered users and 2 guests

cron