?
Solved

PHP 5: session_start() without any other statement still outputs "Cannot send session..." warning

Posted on 2007-12-04
15
Medium Priority
?
1,360 Views
Last Modified: 2013-12-13
Here is my test.php.
<?php
session_start();
phpinfo();
?>

It displays the 2 lines of Warning "Cannot send session..." and then displays phpinfo correctly.
As you see there is nothing (not even a space), before session_start()

php.ini file has : session.save_path = "C:\dev\A_M_P\tmp"
I do see that the session file is created in this directory EVERYTIME I load the test page.

I googled, and people say I might have some character at the end of Config.php's ?>.
I verified and I don't have.

This is my first time using session for PHP. I do see that a new session file is created every time I acces the test.php. What else could be wrong unless XAMPP package is buggy?

Steve
0
Comment
Question by:shahnweb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 3
  • +2
15 Comments
 
LVL 21

Expert Comment

by:nizsmo
ID: 20407882
<?php session_start(); ?>
<?php echo "test"; ?>


save that as a php file, does it work or do you still get error?
0
 

Author Comment

by:shahnweb
ID: 20407946
Yes, exactly same errors.  And I always see the output(in this case 'test'). Session file is keep created un the tmp directory..
0
 
LVL 21

Accepted Solution

by:
nizsmo earned 300 total points
ID: 20407975
ok, go to view source in your browser, can you see anything before the 'test'??
Remember to check that 'test' is the very first line, and has no spaces or returns (newline) before it.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:shahnweb
ID: 20408119
The following below of the dotted line is the exact cut and past from the view source.
I don't see anything except the error mesage.
------------------------------
<br />
<b>Warning</b>:  session_start() [<a href='function.session-start'>function.session-start</a>]: Cannot send session cookie - headers already sent by (output started at C:\webroot\goodvibe\php\test.php:1) in <b>C:\webroot\goodvibe\php\test.php</b> on line <b>1</b><br />
<br />
<b>Warning</b>:  session_start() [<a href='function.session-start'>function.session-start</a>]: Cannot send session cache limiter - headers already sent (output started at C:\webroot\goodvibe\php\test.php:1) in <b>C:\webroot\goodvibe\php\test.php</b> on line <b>1</b><br />
test
0
 
LVL 10

Expert Comment

by:wildzero
ID: 20408299
Just wondering, do you have something in your .htaccess / apache config where it is always loading another PHP file first.

something like
php_value auto_prepend_file "somefile.php"
0
 

Author Comment

by:shahnweb
ID: 20408392
I scanned the directory and found total 3 .htaccess files with the contents like below.
I'm not sure what Deny from all means here, but I don't find any thing appending output.  Both Apache and MySQL are from XAMPP package for my Windows XP.

#1 C:\dev\A_M_P\htdocs\forbidden\.htaccess
AuthType Basic
AuthName "FORBIDDEN AREA"
AuthUserfile "../htdocs/forbidden/.htpasswd"
Require valid-user

#2 C:\dev\A_M_P\phpMyAdmin\libraries\.htaccess
# This folder does not require access over HTTP
# (the following directive denies access by default)
Order allow,deny

#3 C:\dev\A_M_P\htdocs\xampp\sqllite\.htaccess
Order deny,allow
Deny from all
0
 
LVL 10

Assisted Solution

by:wildzero
wildzero earned 300 total points
ID: 20408403
Hmm odd
and in your file
<? session_start(); ?>
is at the very very top with no white space (not even a single space) ?
0
 
LVL 21

Expert Comment

by:nizsmo
ID: 20408422
very odd indeed. Try the script i posted above on another host, see if it works?
0
 

Author Comment

by:shahnweb
ID: 20409073
I found the solution!
The cuprit was my SEPY ActionScript editor.(which supports PHP highlighting).
I have compared the same PHP statement written by notepad, and SEPY adds garbages at the beginnig as below. I don't know why SEPY does this, but I will not use this editor again.

BTW, can anybody suggest a good editor for PHP and ActionScript?  (I have Adobe Master Suite CS3)
Thanks nizsmo and wildzero for your effort.

C:\webroot>type test.php
<?php session_start(); ?>
<?php echo "test"; ?>
C:\webroot>type testSepy.php
)W<?php session_start(); ?>
<?php echo "test"; ?>

0
 
LVL 21

Assisted Solution

by:nizsmo
nizsmo earned 300 total points
ID: 20409472
i see! glad you found solution!

My suggestion for PHP editing would be Zend Studio!
http://zend.com/en/products/studio

In my opinion by far the best editor there is for PHP, you can also to a certain extent use Dreamweaver, PHPEclipse, etc...

Hope this helps! :)
0
 
LVL 10

Assisted Solution

by:wildzero
wildzero earned 300 total points
ID: 20410089
Yay :-)
http://www.eclipse.org/pdt/
That is the editor I have been using lately, Zend Studio is going to start using it (as you can see from Zends beta release's). However eclipse is free!
0
 
LVL 9

Assisted Solution

by:tkalchev
tkalchev earned 150 total points
ID: 20450652
SEPY is saving the .php files in UFT-8 format, php still have some problems executing them ... Change the settings of your editor and specify an encoding different then UTF-8
0
 

Author Comment

by:shahnweb
ID: 20454223
SEPY also works if I save it using ASCII mode.

The question now is how to input non-ASCII foreign languge error message in PHP?

For example, if I include "error.php" that includes UTF-8 based error message in a php file that uses $xml->asXML(), the statement fails since the include file contains 'garbage' bytes(2) what tags UTF-8 file.

0
 
LVL 9

Expert Comment

by:tkalchev
ID: 20455934
Try to write only the messages into an external unicode file (.txt for example), then load it in the php code, using file_get_contents. Leave the php source in ASCII. This should work.
0
 
LVL 1

Expert Comment

by:a53mp
ID: 21224408
I recommend crimsoneditor.com for editing PHP files.
0

Featured Post

WordPress Tutorial 4: Recommended Plugins

Now that you have WordPress installed, understand the interface, and know how to install new parts, let’s take a look at our recommended plugins.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question