Warning: Session_start() [function.session-start]: Cannot Send Session
Post Description: warning: session_start() [function.session-start]: cannot send session
warning, session, start, functionsession, start, cannot, send, session
This Post Has Been Viewed 11195 Times Since Fri Feb 29, 2008 12:01 pm Posted By web hosting with 25 replies
POST# 336
Posted On: Fri Feb 29, 2008 12:01 pm
Topic: Warning: Session_start() [function.session-start]: Cannot Send Session
The other day i kept getting this error:
Code: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 2 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
Mon Feb 05, 2007 6:18 pm
2
.::kmfp::.
Reply #911
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::.
Mon Feb 05, 2007 9:05 pm
3
hostman
Reply #912
hello .::kmfp::. , glad i could help. Yo Hablo Espanol Amigo!
Thu Jun 21, 2007 5:14 am
4
Calil
Reply #913
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.
Fri Jul 13, 2007 2:46 am
5
jin
Reply #914
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?
Fri Jul 13, 2007 7:24 am
6
hostman
Reply #915
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.
Sat Jul 21, 2007 1:43 am
7
shasha
Reply #916
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:xampplitehtdocscityindex.php:1) in e:xampplitehtdocscityindex.php on line 2
nothing previous to session_start except php tag
if you have any suggestion
thanks alot
Sat Jul 21, 2007 9:14 am
8
hostman
Reply #917
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()
Sat Aug 11, 2007 2:40 am
9
Errpor
Reply #918
warning: cannot send session cache limiter - headers already sent (output started at c:apachehtdocsdhakanewsoraclememberindex.php:1) in c:apachehtdocsdhakanewsoraclememberindex.php on line 2
Mon Aug 13, 2007 11:35 am
10
yellow
Reply #919
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
Sun Sep 09, 2007 1:28 pm
11
Maciej
Reply #920
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++
Mon Nov 19, 2007 4:21 am
12
amit
Reply #921
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
Mon Nov 19, 2007 4:23 am
13
amit sinha
Reply #922
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
Sun Nov 25, 2007 10:30 pm
14
amit
Reply #923
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
Mon Nov 26, 2007 5:47 pm
15
sri
Reply #924
thankyou, it helped.
Tue Nov 27, 2007 4:48 am
16
Rajasekhar and anil
Reply #925
thanks very much . i got the solution of my error. it's very useful to the new learners. thanks a lot.............
Mon Dec 03, 2007 5:50 pm
17
SIMILAR ERROR
Reply #926
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?
Fri Dec 07, 2007 7:14 pm
18
gipss
Reply #927
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);
}
Thu Dec 20, 2007 9:41 pm
19
ranjani
Reply #928
thanks a lot.. it really helped me..
Sun Dec 30, 2007 3:22 pm
20
Adriani
Reply #929
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
Mon Dec 31, 2007 9:02 am
21
anggi
Reply #930
angie is the coolers
Wed Jan 30, 2008 10:44 pm
22
suma
Reply #931
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.
Mon Feb 04, 2008 12:14 pm
23
Logan
Reply #932
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...
Mon Feb 04, 2008 12:36 pm
24
hostman
Reply #933
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
Sun Feb 24, 2008 8:55 pm
25
rancid
Reply #934
thanks...phew that worked for me...thanks again