Warning: session_start() [function.session-start]: Cannot send session
Post Description: warning session start functionsession start cannot send session PHP
Post Tags:
This Post Has Been Viewed 27480 Times Since Mon Sep 25, 2006 6:00 pm Author
hostman with 70 replies
Warning: session_start() [function.session-start]: Cannot send session
Advertise On This Page
Note: If you are using cookie-based sessions, you must call session_start() before anything is outputted to the browser.
The other day i kept getting this error:
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /var/www/a-header.php:10) in /var/www/header.php on line 26
so to fix it I moved the session_start() function from line 26 to line 1 on my header.php file.
That fixed it.
I am posting here just incase anyone else is getting it..
If you have benefited from this post, wallpaperama would appreciate a link back to wallpaperama.com - Thanks
Description
bool session_start ( void )
session_start() creates a session or resumes the current one based on the current session id that's being passed via a request, such as GET, POST, or a cookie.
If you want to use a named session, you must call session_name() before calling session_start().
session_start() will register internal output handler for URL rewriting when trans-sid is enabled. If a user uses ob_gzhandler or like with ob_start(), the order of output handler is important for proper output. For example, user must register ob_gzhandler before session start.
Notes
Note: If you are using cookie-based sessions, you must call session_start() before anything is outputted to the browser.
Links Related to : Warning: session_start() [function.session-start]: Cannot send session
Comments and replies About Warning: session_start() [function.session-start]: Cannot send session
::
1 ::
Reply #126264 Reply By
Mohsin On Tue Jan 19, 2010 11:50 am
Mohsin:
How Can i solve This error:
Warning: session_start() [function.session-start]: open(C:\Windows\SERVIC~2\ O_RDWR) failed: Permission denied (13) in C:\inetpub\wwwroot\ses.ph on line 10
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\inetpub\wwwroot\ses.ph in C:\inetpub\wwwroot\ses.ph on line 10
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\inetpub\wwwroot\ses.ph in C:\inetpub\wwwroot\ses.ph on line 10
Pageviews = 1
Warning: Unknown: open(C:\Windows\SERVIC~2\ O_RDWR) failed: Permission denied (13) in Unknown on line 0
Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct () in Unknown on line 0
::
2 ::
Reply #125488 Reply By
Prageeth On Wed Jan 06, 2010 1:55 am
Prageeth:
i spend lot of time in google but only this is one is the very best answer finall i got.
thank very much for this post...
::
3 ::
Reply #118317 Reply By
ashley On Mon Oct 19, 2009 8:54 pm
ashley:
tnx for this.,
it helped me solve my problem ^^
godbless
Ei:
hi.....
i got this problems two days ready.
it works for me.
thanks alot!!!! :d
::
5 ::
Reply #113486 Reply By
hcmshare On Sat Aug 22, 2009 5:43 am
hcmshare:
thanks.
i could share a tip for you about :
session_start error :
1. the <?php must be left top corner
2. session_start at the first line
i did and gain a good results.
if you like this, please visit us at
hcmshare
::
6 ::
Reply #111058 Reply By
arunjirain On Thu Jul 30, 2009 2:48 am
arunjirain:
i have faced this error at several occasions.an easy way to tackle is
place
<?php session_start(); ?>
as the top most line of the page.
try to write it in a single line itself.make it a practise and i hope you wont be in trouble in future.
::
7 ::
Reply #108872 Reply By
scvinodkumar On Fri Jul 10, 2009 1:33 am
scvinodkumar:
you can also use ob_start() to clear the headers.
::
8 ::
Reply #107408 Reply By
nilatpol On Fri Jun 26, 2009 1:16 am
nilatpol:
i have got similar problem, but i know nothing about php, can any one guide me to solve these?
warning: session_start() [function.session-start]: cannot send session cookie - headers already sent by (output started at /home/localmat/public_html/index.ph in /home/localmat/public_html/index.ph on line 6
warning: session_start() [function.session-start]: cannot send session cache limiter - headers already sent (output started at /home/localmat/public_html/index.ph in /home/localmat/public_html/index.ph on line 6
::
9 ::
Reply #100633 Reply By
Desika On Fri Apr 17, 2009 3:45 pm
Desika:
thank you very much.it has helped me to do my programme.
::
10 ::
Reply #100401 Reply By
magic_Marc On Wed Apr 15, 2009 6:00 am
magic_Marc:
thank you. this solved my problem!!
::
11 ::
Reply #99775 Reply By
Igor On Wed Apr 08, 2009 12:24 pm
Igor:
thanks man you are amazing.
i work on this problem all week.
thanks again.....
::
12 ::
Reply #92657 Reply By
Makbaig On Tue Feb 03, 2009 11:03 pm
Makbaig:
nice solution. i got it when i placed in the line 1.
thanks for this post...
::
13 ::
Reply #92183 Reply By
clutch123 On Sat Jan 31, 2009 1:09 am
clutch123:
thanks for the post. it was really helpful.
::
14 ::
Reply #89553 Reply By
amanda On Sat Jan 10, 2009 11:22 pm
amanda:
thanks man you are amazing
::
15 ::
Reply #88165 Reply By
Klaus On Wed Dec 31, 2008 12:33 am
Klaus:
i placed session_start on line 2 (after ?php) and problem was solved -> thank you.
::
16 ::
Reply #87500 Reply By
sara On Wed Dec 24, 2008 7:12 pm
sara:
hi i set my session on top but i still this kind of problem please help me to solve this problems
i put mu session on line 1 .
::
17 ::
Reply #85301 Reply By
yyyy On Mon Dec 08, 2008 1:50 am
yyyy:
how to solve this problem:
warning: session_start() [function.session-start]: cannot send session cookie - headers already sent by (output started at c:\inetpub\vhosts\imi.in\httpdo in c:\inetpub\vhosts\imi.in\httpdo on line 3
::
18 ::
Reply #84570 Reply By
Craig On Wed Dec 03, 2008 2:33 pm
Craig:
i had a similar problem - only way i could fix it was to login to my control panel and change the code in the wysiwyg editor as there two strange letters showing up before the opening php tag.
i use editpad to code all my work and its the first time this has ever happened to me! very strange.
::
19 ::
Reply #83807 Reply By
phpfreechat On Fri Nov 28, 2008 10:04 am
phpfreechat:
this is my errror: phpfreechat warning: session_start() [function.session-start]: cannot send session cache limiter - headers already sent
::
20 ::
Reply #80737 Reply By
Mahmud On Tue Nov 11, 2008 9:48 pm
Mahmud:
warning: session_start() [function.session-start]: cannot send session cookie - headers already sent by (output started at d:\www\myspurring\homepage.php:1 in d:\www\myspurring\homepage.php on line 2
warning: session_start() [function.session-start]: cannot send session cache limiter - headers already sent (output started at d:\www\myspurring\homepage.php:1 in d:\www\myspurring\homepage.php on line 2
i have index page which include homepage.php
at the begining of the homepage.php i started session by
session_start() function and i am getting the error.
there is nothing before it( output).
i have tried variations... like once i tried starting session in index.php and including homepage.php after that
still i am getting the same error.... i am screwed up...as a new comer...
could anyone help me..
thanks well in advance
::
21 ::
Reply #78391 Reply By
Gerhard On Thu Oct 30, 2008 4:30 am
Gerhard:
thanks a lot. a solution that works!
::
22 ::
Reply #77771 Reply By
rus On Mon Oct 27, 2008 11:44 am
rus:
warning: session_start() [function.session-start]: cannot send session cache limiter - headers already sent (output started at c:\program files\xampp\htdocs\new_fleet\cl in c:\program files\xampp\htdocs\new_fleet\in on line 6
can u help me with this
::
23 ::
Reply #76765 Reply By
ledine On Wed Oct 22, 2008 12:54 pm
ledine:
thanks for that note! it fixed my issue up right away... after trying just about everything else i could think of!
::
24 ::
Reply #75983 Reply By
umer On Fri Oct 17, 2008 9:00 pm
umer:
pleas help me to solve this problem when i write session_star() the following warning message will send
warning: session_start() [function.session-start]: cannot send session cookie - headers already sent in php
::
25 ::
Reply #75242 Reply By
tinkerangel On Mon Oct 13, 2008 2:22 am
tinkerangel:
waw! you fixed my problem too! thanks anyway!
::
26 ::
Reply #74282 Reply By
Harry On Tue Oct 07, 2008 12:41 am
::
27 ::
Reply #72100 Reply By
Sumeet On Thu Sep 25, 2008 2:59 am
Sumeet:
can any one help me with this
warning: session_start() [function.session-start]: cannot send session cookie - headers already sent by (output started at /home/content/p/u/n/puneetagg/html/ in /home/content/p/u/n/puneetagg/html/ on line 1
i tried everything mentioned here.
::
28 ::
Reply #71769 Reply By
Bogdan On Tue Sep 23, 2008 5:37 am
Bogdan:
thank you guys ! the utf-8 encodig was my problem. now cahnged to utf-8 without byte order mark and now everything is perfect !!
thank you !
::
29 ::
Reply #68147 Reply By
Evie On Mon Aug 25, 2008 7:06 pm
Evie:
oops! here's the whole thing.
session_start();
w mysql_connect() [function.mysql-connect]: can't connect to local mysql server through socket '/var/run/mysqld/mysqld.sock' (2) in /hermes/bosweb/web218/b2186/sl.poly on line 13
warning: mysql_get_server_info(): supplied argument is not a valid mysql-link resource in /hermes/bosweb/web218/b2186/sl.poly on line 14
can't connect to local mysql server through socket '/var/run/mysqld/mysqld.sock' (2)
::
30 ::
Reply #68146 Reply By
Evie On Mon Aug 25, 2008 7:04 pm
Evie:
can someone help me with this? i got the other error and moved the session_start(); to line one and now it's just showing this. plus the other errors. i just need help. thanks!!
session_sta mysql_connect() [function.mysql-connect]: can't connect to local mysql server through socket '/var/run/mysqld/mysqld.sock' (2) in /hermes/bosweb/web218/b2186/sl.poly on line 13
warning: mysql_get_server_info(): supplied argument is not a valid mysql-link resource in /hermes/bosweb/web218/b2186/sl.poly on line 14
can't connect to local mysql server through socket '/var/run/mysqld/mysqld.sock' (2)
::
31 ::
Reply #66375 Reply By
thangavel On Thu Aug 14, 2008 4:10 am
thangavel:
warning: session_start() [function.session-start]: cannot send session cookie - headers already sent by (output started at /var/www/a-header.php:10) in /var/www/my.php on line 4
::
32 ::
Reply #62935 Reply By
dan On Wed Jul 23, 2008 1:39 am
dan:
aye m8, thnx for help ;)
::
33 ::
Reply #58827 Reply By
Someone On Sun Jun 22, 2008 8:40 am
Someone:
hello,
the post helped me. i got the same error with my php script when i uploaded it to my web-server. moving the 'session_start()' to the top, ie line 2 fixed the problem.... cheers....
::
34 ::
Reply #56059 Reply By
cosi On Sun Jun 01, 2008 10:44 am
cosi:
thanks! it was useful for me too.
::
35 ::
Reply #55348 Reply By
carbsk On Tue May 27, 2008 6:07 am
carbsk:
perfect solution!
regards.
::
36 ::
Reply #54133 Reply By
maggie On Sat May 17, 2008 9:25 am
maggie:
thanks!!! the error is deleted!!!
::
37 ::
Reply #54108 Reply By
hostman On Sat May 17, 2008 6:57 am
hostman:
hmm, from the looks of it, you have a captcha file. dont include the captcha file as a inlcude, rather, call it through your HTML like this:
<img src="http://www.yourstie.com/captcha/p" alt="captcha image">
::
38 ::
Reply #54106 Reply By
maggie On Sat May 17, 2008 6:42 am
maggie:
hi!!!
i've got this problem on my site:
warning: session_start() [function.session-start]: cannot send session cookie - headers already sent by (output started at /home/lconrad/public_html/header.ph in /home/lconrad/public_html/captcha/p on line 46
warning: session_start() [function.session-start]: cannot send session cache limiter - headers already sent (output started at /home/lconrad/public_html/header.ph in /home/lconrad/public_html/captcha/p on line 46
could you help me??? thanks!
::
39 ::
Reply #53904 Reply By
Alex On Thu May 15, 2008 9:02 am
Alex:
help!!! how can i fix the problem below:
warning: session_start() [function.session-start]: open(/tmp/sess_37df5aa9c11e29d0a4f3 o_rdwr) failed: permission denied (13) in /home/nigeria/public_html/index.php on line 2
warning: session_start() [function.session-start]: cannot send session cache limiter - headers already sent (output started at /home/nigeria/public_html/index.php in /home/nigeria/public_html/index.php on line 2
warning: cannot modify header information - headers already sent by (output started at /home/nigeria/public_html/index.php in /home/nigeria/public_html/index.php on line 25
::
40 ::
Reply #53477 Reply By
mick On Mon May 12, 2008 1:48 am
mick:
utf-8 without bom fixed my session_start() errors. thanks.
to actually see the bom i opened the page in cpanel's editor in iso-8859-1, it didn't show in utf-8,.... go figure.
my page was created from a dream weaver template while edit - preferences - new document was set to utf-8 with bom. save-as utf-8 no bom only worked for first save , then ctrl s defaults back to utf-8 with bom (grumble...)
i regained control by changing edit - preferences - new document to utf-8 with no bom. then created new document from template and copied my php and html from the troublesome page(which i then joyfully deleted) to the new one.
thats the contact page done, now for the shopping cart.(cross fingers)
::
41 ::
Reply #53456 Reply By
sam On Sun May 11, 2008 8:14 pm
sam:
thanks a lot. really appreciate the help. the utf-8 without bom is my solution
::
42 ::
Reply #53049 Reply By
herman On Wed May 07, 2008 11:18 pm
herman:
is also get this session start error
but i have no session start() in the page that is sais it is doing again
::
43 ::
Reply #50045 Reply By
victor On Mon Apr 14, 2008 7:56 am
victor:
thanks, you saved my day
::
44 ::
Reply #49406 Reply By
vikal On Thu Apr 10, 2008 12:13 am
vikal:
administrator/includes/toolbar.php
remove the blank lines at the end of file....
::
45 ::
Reply #49405 Reply By
vikal On Thu Apr 10, 2008 12:12 am
vikal:
administrator/includes/toolbar.php the blank lines at the end of file....
::
46 ::
Reply #42996 Reply By
rancid On Sun Feb 24, 2008 8:55 pm
rancid:
thanks...phew that worked for me...thanks again
::
47 ::
Reply #39742 Reply By
hostman On Mon Feb 04, 2008 12:36 pm
hostman:
if that's the case, then you need to check any of your includes, check for any blanks or white spaces on line one of any of the files, if you are getting this errors, its because you are sending some information to the browser before the sessionstart function. you just have to check and doublecheck, eventually, you will find it. it happened to me, i went crazy trying to find it, but eventually, i found it. just remember, you can't have anything before sessionstart
you can also get more help at:
http://www.php.net/manual/en/function.session-start.php
Description
bool session_start ( void )
session_start() creates a session or resumes the current one based on the current session id that's being passed via a request, such as GET, POST, or a cookie.
If you want to use a named session, you must call session_name() before calling session_start().
session_start() will register internal output handler for URL rewriting when trans-sid is enabled. If a user uses ob_gzhandler or like with ob_start(), the order of output handler is important for proper output. For example, user must register ob_gzhandler before session start.
Notes
Note: If you are using cookie-based sessions, you must call session_start() before anything is outputted to the browser.
as you can see, even the official php site says you must call session_start() before anything you send to the browser, that includes white spaces. white spaces are hard to find, because you can't see them, you have to look for them
::
48 ::
Reply #39741 Reply By
Logan On Mon Feb 04, 2008 12:14 pm
Logan:
this doesn't help me one tiny bit... i'm getting the error being reported on line 1 - all that's on that line is a session starter...
::
49 ::
Reply #39015 Reply By
suma On Wed Jan 30, 2008 10:44 pm
suma:
thanks you helped me a lot .i could rectify the errors.,and finally it working good.
i removed the extra "session start();" from the page and removed the extra header lines from the page expire .php,so it woring fine.
::
50 ::
Reply #33833 Reply By
anggi On Mon Dec 31, 2007 9:02 am
anggi:
angie is the coolers