Warning: Session_start() [function.session-start]: Cannot Send Session
Post Description:
Post Tags: warning, session, start, functionsession, start, cannot, send, session
This Post Has Been Viewed 17243 Times Since Mon Sep 25, 2006 6:00 pm Posted By hostman with 38 replies
| Warning: Session_start() [function.session-start]: Cannot Send Session |
|
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.
Leave Your Comments [ dejar commentarios ]
Comments and replies About Warning: Session_start() [function.session-start]: Cannot Send Session
:: 1 :: #123 - Reply By hostman On Thu Sep 28, 2006 12:39 am
you can get more information about this error on this link below:
session_start() Function Help

:: 2 :: #197 - Reply By .::kmfp::. On Mon Feb 05, 2007 6:18 pm
Thx a Lot!! This was my solution.
I put all session_start() at the begening, and thats it!
(sorry about my english, I'm spanish speaker)
Thx again...
.::kmfp::.
:: 3 :: #202 - Reply By hostman On Mon Feb 05, 2007 9:05 pm
hello .::kmfp::. , glad i could help. Yo Hablo Espanol Amigo!
:: 4 :: #7505 - Reply By Calil On Thu Jun 21, 2007 5:14 am
hey dude, thanks a lot.
i got the solution here too.
just in case someone gets this lil' problem too, the session_start() must be the first line, even before the doctype declare.
:: 5 :: #10705 - Reply By jin On Fri Jul 13, 2007 2:46 am
thx,but:
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 1
can you help?
:: 6 :: #10722 - Reply By hostman On Fri Jul 13, 2007 7:24 am
what this is telling you is that session_start() has already been executed in header.php on line one, now you are trying to send session_start() again on a-header.php.
very simple to fix your problem, remove session_start() from a-header.php on line 10.
:: 7 :: #11903 - Reply By shasha On Sat Jul 21, 2007 1:43 am
i always declare session_start at the beggining of page index which include any other file but i have that error
warning: session_start() [function.session-start]: cannot send session cookie - headers already sent by (output started at e:\xampplite\htdocs\city\index.php:1) in e:\xampplite\htdocs\city\index.php on line 2
nothing previous to session_start except php tag
if you have any suggestion
thanks alot
:: 8 :: #11919 - Reply By hostman On Sat Jul 21, 2007 9:14 am
make sure that your script starts like this:
Line 1: <?
Line 2: session_start();
becareful and look cosely, because you might have something like this:
line 1:
Line 2: <?
Line 3: session_start();
as you can see, line 1 is empty, so there might be a white space like a space character. you can't have anything before declaring session_start()
:: 9 :: #15288 - Reply By Errpor On Sat Aug 11, 2007 2:40 am
warning: cannot send session cache limiter - headers already sent (output started at c:\apache\htdocs\dhakanewsoracle\member\index.php:1) in c:\apache\htdocs\dhakanewsoracle\member\index.php on line 2
:: 10 :: #15578 - Reply By yellow On Mon Aug 13, 2007 11:35 am
also remeber that if ur coding in utf-8 all document it's sending 'bom' - it is always 3 invisible characters before script starts
so change coding or use coding utf-8 without bom
notepad++ has it, u can get it at sf.net
:: 11 :: #19524 - Reply By Maciej On Sun Sep 09, 2007 1:28 pm
guys, thanks a lot for explaining the issue with utf encoding with bom. i had same problem like the fellow below me but managed to solve it. all i needed to do was to change conding to utf8 without bom in notepad++
:: 12 :: #28275 - Reply By amit On Mon Nov 19, 2007 4:21 am
error: [2] session_start() [function.session-start]: cannot send session cookie - headers already sent by (output started at /home/allkindt/public_html/shared/config/tce_db_config.php:180) | line: 190 | file: /home/allkindt/public_html/shared/code/tce_functions_session.php
error: [2] session_start() [function.session-start]: cannot send session cache limiter - headers already sent (output started at /home/allkindt/public_html/shared/config/tce_db_config.php:180) | line: 190 | file: /home/allkindt/public_html/shared/code/tce_functions_session.php
error: [2] cannot modify header information - headers already sent by (output started at /home/allkindt/public_html/shared/config/tce_db_config.php:180) | line: 191 | file: /home/allkindt/public_html/shared/code/tce_functions_session.php
hi i face this problems..please give me a better solution....thanks..byeee
:: 13 :: #28276 - Reply By amit sinha On Mon Nov 19, 2007 4:23 am
error: [2] unpack() [function.unpack]: type n: not enough input, need 4, have 0 | line: 3099 | file: /home/allkindt/public_html/shared/code/tcpdf.php
error: [2] cannot modify header information - headers already sent by (output started at /home/allkindt/public_html/shared/config/tce_db_config.php:180) | line: 2409 | file: /home/allkindt/public_html/shared/code/tcpdf.php
tcpdf error: some data has already been output to browser, can't send pdf file
i face this problems to create pdf file
:: 14 :: #29303 - Reply By amit On Sun Nov 25, 2007 10:30 pm
error: [2] unpack() [function.unpack]: type n: not enough input, need 4, have 0 | line: 3099 | file: /home/allkindt/public_html/shared/code/tcpdf.php
tcpdf error: some data has already been output, can't send pdf file
:: 15 :: #29399 - Reply By sri On Mon Nov 26, 2007 5:47 pm
thankyou, it helped.
:: 16 :: #29448 - Reply By Rajasekhar and anil On Tue Nov 27, 2007 4:48 am
thanks very much . i got the solution of my error. it's very useful to the new learners. thanks a lot.............
:: 17 :: #30438 - Reply By SIMILAR ERROR On Mon Dec 03, 2007 5:50 pm
i was able to fix the error on the cookies when placing them on the first lines. however, i have a similar error with header("location:mypage.php"); the error displayed is
warning: cannot modify header information - headers already sent by (output started at /home/mydomain/public_html/mypage_add.php:4) in /home/mydomain/public_html/mypage_add.php on line 72.
the following are the codes:
71: if ($resultpage){
72: header("location:detail.php?name_id=$name_id#p$page_id");
73: exit();
74: }else{
what seems to be the problem?
:: 18 :: #30912 - Reply By gipss On Fri Dec 07, 2007 7:14 pm
still having it... though i tried every solution in this topic
warning: session_start() [function.session-start]: cannot send session cache limiter - headers already sent (output started at /home/admin/public_html/zaid/htpre/userclass.php:62) in /home/admin/public_html/zaid/htpre/sessiondata.php on line 28
this is the sessiondata.php and the error in
if ($sid == "") {
session_start();
$sid = session_id();
} else {
session_start($sid);
}
:: 19 :: #32450 - Reply By ranjani On Thu Dec 20, 2007 9:41 pm
thanks a lot.. it really helped me..
:: 20 :: #33728 - Reply By Adriani On Sun Dec 30, 2007 3:22 pm
who help me about this error
warning: session_start() [function.session-start]: open(/var/tmp/sess_519142a978e7bec6c052145fa892aca3, o_rdwr) failed: permission denied (13) in /mnt/web1/22/58/51474058/htdocs/kd/korenicajomla/joomla_1.0.13-stable-full_package/includes/joomla.php on line 800
warning: session_start() [function.session-start]: cannot send session cookie - headers already sent by (output started at /mnt/web1/22/58/51474058/htdocs/kd/korenicajomla/joomla_1.0.13-stable-full_package/includes/joomla.php:800) in /mnt/web1/22/58/51474058/htdocs/kd/korenicajomla/joomla_1.0.13-stable-full_package/includes/joomla.php on line 800
warning: session_start() [function.session-start]: cannot send session cache limiter - headers already sent (output started at /mnt/web1/22/58/51474058/htdocs/kd/korenicajomla/joomla_1.0.13-stable-full_package/includes/joomla.php:800) in /mnt/web1/22/58/51474058/htdocs/kd/korenicajomla/joomla_1.0.13-stable-full_package/includes/joomla.php on line 800
this error i have in administration panel
:: 21 :: #33833 - Reply By anggi On Mon Dec 31, 2007 9:02 am
angie is the coolers
:: 22 :: #39015 - Reply By suma On Wed Jan 30, 2008 10:44 pm
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.
:: 23 :: #39741 - Reply By Logan On Mon Feb 04, 2008 12:14 pm
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...
:: 24 :: #39742 - Reply By hostman On Mon Feb 04, 2008 12:36 pm
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
:: 25 :: #42996 - Reply By rancid On Sun Feb 24, 2008 8:55 pm
thanks...phew that worked for me...thanks again
:: 26 :: #49405 - Reply By vikal sen On Thu Apr 10, 2008 12:12 am
administrator/includes/toolbar.php the blank lines at the end of file....
:: 27 :: #49406 - Reply By vikal On Thu Apr 10, 2008 12:13 am
administrator/includes/toolbar.php
remove the blank lines at the end of file....
:: 28 :: #50045 - Reply By victor On Mon Apr 14, 2008 7:56 am
thanks, you saved my day
:: 29 :: #53049 - Reply By herman On Wed May 07, 2008 11:18 pm
is also get this session start error
but i have no session start() in the page that is sais it is doing again
:: 30 :: #53456 - Reply By sam On Sun May 11, 2008 8:14 pm
thanks a lot. really appreciate the help. the utf-8 without bom is my solution
:: 31 :: #53477 - Reply By mick On Mon May 12, 2008 1:48 am
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)
:: 32 :: #53904 - Reply By Alex On Thu May 15, 2008 9:02 am
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
:: 33 :: #54106 - Reply By maggie On Sat May 17, 2008 6:42 am
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!
:: 34 :: #54108 - Reply By hostman On Sat May 17, 2008 6:57 am
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">
:: 35 :: #54133 - Reply By maggie On Sat May 17, 2008 9:25 am
thanks!!! the error is deleted!!!
:: 36 :: #55348 - Reply By carbsk On Tue May 27, 2008 6:07 am
perfect solution!
regards.
:: 37 :: #56059 - Reply By cosi On Sun Jun 01, 2008 10:44 am
thanks! it was useful for me too.
:: 38 :: #58827 - Reply By Someone On Sun Jun 22, 2008 8:40 am
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....