session problem.

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
awdhut
Forum Newbie
Posts: 5
Joined: Fri Oct 30, 2009 11:34 am

session problem.

Post by awdhut »

The following message is appearing with o/p.
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/hope/public_html/dnb1.php:1) in /home/hope/public_html/dnb1.php on line 3.

1) I'm using UTF-8 collation in database.
2) I put session start function at top of document.
3) I tried ob_start("ob_gzhandler") Function.
4) I saved my document in utf-8 excluding BOM.
5) i'm using Session variable to transfer tha data from one file to another.
I tried all possibilities which i know.
I get the required o/p BUT the above message is appearing on the top of o/p.
How can i remove the msg.
Help me.
User avatar
manohoo
Forum Contributor
Posts: 201
Joined: Wed Dec 23, 2009 12:28 pm

Re: session problem.

Post by manohoo »

Post your code, if you require or include files, also post that code.
User avatar
Apollo
Forum Regular
Posts: 794
Joined: Wed Apr 30, 2008 2:34 am

Re: session problem.

Post by Apollo »

The session_start function creates a cookie. This must be done before outputting any HTML. Most likely you have already outputted something in your .php before you call session_start, so you gotta do it the other way round.

Note that this does not apply to reading or writing actual session variables, that's something 100% server side and can be done anywhere in the .php you want (well, after session_start, that is).
User avatar
ricky-ham
Forum Newbie
Posts: 9
Joined: Mon Dec 28, 2009 2:17 am

Re: session problem.

Post by ricky-ham »

I had some of the same problems when I started to leran about the session and cookie. Like the comment above. Make sure that there is no output to the screen before your session. This will include any html or the doctype of the document.
Post Reply