Help me please with session

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
Lex82
Forum Newbie
Posts: 4
Joined: Fri Mar 23, 2007 10:09 am
Location: Ukraine

Help me please with session

Post by Lex82 »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


My script is beginning from:

Code: Select all

<?php
  error_reporting( E_ALL & ~E_NOTICE );
  session_start(); ...
When I am using an interpreter I get messages:

Warning: session_start(): Cannot send session cookie – headers already sent in D:\dane\worck space\mgmt_main_Temp.phtml on line 3

Warning: session_start(): Cannot send session cache limiter – headers already sent (output started at D:\dane\worck space\mgmt_main_Temp.phtml:3) in D:\dane\worck space\mgmt_main_Temp.phtml on line 3

What is this kind of problem and how to resolve it
:?:


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

[quote="[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1"][b]11.[/b] Please use proper, complete spelling when posting in the forums. AOL Speak, leet speak and other abbreviated wording can confuse those that are trying to help you (or those that you are trying to help). Please keep in mind that there are many people from many countries that use our forums to read, post and learn. They do not always speak English as well as some of us, nor do they know these aberrant abbreviations. Therefore, use as few abbreviations as possible, especially when using such simple words.

Some examples of what not to do are ne1, any1 (anyone); u (you); ur (your or you're); 2 (to too); prolly (probably); afaik (as far as I know); etc.[/quote]
mentor
Forum Contributor
Posts: 100
Joined: Sun Mar 11, 2007 11:10 am
Location: Pakistan

Post by mentor »

There is some sort of output on line in 3 mgmt_main_Temp.phtml. This can be some whitespace, empty string etc.
Lex82
Forum Newbie
Posts: 4
Joined: Fri Mar 23, 2007 10:09 am
Location: Ukraine

Post by Lex82 »

I'm realy beginer of PHP :roll: May be some one know some web sites when I can read about solutions of this problem.
sarbas
Forum Commoner
Posts: 64
Joined: Thu Jan 04, 2007 5:51 am

hi

Post by sarbas »

hi Lex82,

You should start the session at the beginning line.
for Example

Code: Select all

<?php
  session_start(); 
  error_reporting( E_ALL & ~E_NOTICE );
?>
try this one.

Thanks with Regards
Sarbas
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

error_reporting does not output anything. headers sent means that you are trying to send response headers after already outputting something to the browser. The most typical reason behind this is outputting HTML before the call to session_start(), setcookie() and header(). Those functions, because of what they do, need to be called before any output is sent to the browser.

As has been mentioned earlier, check the file that is referencing in the warning. At line 3 something is being output. It is not a problem, just a code flow issue.
Post Reply