Warning: session_start() [function.session-start]: Cannot se

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
hatrena
Forum Newbie
Posts: 7
Joined: Thu Jan 20, 2011 5:24 am

Warning: session_start() [function.session-start]: Cannot se

Post by hatrena »

hello everyone.
i have an annoying problem.

i have my website in localhost but when i upload it i encounter with these errors:

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/parmissa/public_html/checklogin.php:1) in /home/parmissa/public_html/checklogin.php on line 15

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/parmissa/public_html/checklogin.php:1) in /home/parmissa/public_html/checklogin.php on line 15

Warning: Cannot modify header information - headers already sent by (output started at /home/parmissa/public_html/checklogin.php:1) in /home/parmissa/public_html/checklogin.php on line 35

i search in the internet but the solution could not help me.
please help. please help .please...
User avatar
Mordred
DevNet Resident
Posts: 1579
Joined: Sun Sep 03, 2006 5:19 am
Location: Sofia, Bulgaria

Re: Warning: session_start() [function.session-start]: Canno

Post by Mordred »

You need to start the session before ANY output is sent to the user. This generally means that you need to do this:

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

And not this:

<html>
....
<?php session_start(); ....
hatrena
Forum Newbie
Posts: 7
Joined: Thu Jan 20, 2011 5:24 am

Re: Warning: session_start() [function.session-start]: Canno

Post by hatrena »

i did but nothing.

i realized that i use unicode.utf-8

that's the problem. when i use unicdoe, "a “" will be sent to the beginning of the page . i have to use unicdoe but how can i remove "a “"?

please help
User avatar
Mordred
DevNet Resident
Posts: 1579
Joined: Sun Sep 03, 2006 5:19 am
Location: Sofia, Bulgaria

Re: Warning: session_start() [function.session-start]: Canno

Post by Mordred »

Set your text editor not to use a BOM, this will prevent the output before your session code.
Then, in order to tell the browser that what you send it is utf8, use this in the <header>: <meta http-equiv="Content-Type" content="text /html; charset=UTF-8" />
hatrena
Forum Newbie
Posts: 7
Joined: Thu Jan 20, 2011 5:24 am

Re: Warning: session_start() [function.session-start]: Canno

Post by hatrena »

i did but my web page will be shown in question marks.

i need to use utf-8 and unicode because i have to build a website in Persian not English.
User avatar
Mordred
DevNet Resident
Posts: 1579
Joined: Sun Sep 03, 2006 5:19 am
Location: Sofia, Bulgaria

Re: Warning: session_start() [function.session-start]: Canno

Post by Mordred »

Mordred wrote:Then, in order to tell the browser that what you send it is utf8, use this in the <header>: <meta http-equiv="Content-Type" content="text /html; charset=UTF-8" />
Try it.
Post Reply