• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1398
  • Last Modified:

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

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
shahnweb
Asked:
shahnweb
  • 5
  • 4
  • 3
  • +2
5 Solutions
 
nizsmoDeveloperCommented:
<?php session_start(); ?>
<?php echo "test"; ?>


save that as a php file, does it work or do you still get error?
0
 
shahnwebAuthor Commented:
Yes, exactly same errors.  And I always see the output(in this case 'test'). Session file is keep created un the tmp directory..
0
 
nizsmoDeveloperCommented:
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
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

 
shahnwebAuthor Commented:
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
 
wildzeroCommented:
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
 
shahnwebAuthor Commented:
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
 
wildzeroCommented:
Hmm odd
and in your file
<? session_start(); ?>
is at the very very top with no white space (not even a single space) ?
0
 
nizsmoDeveloperCommented:
very odd indeed. Try the script i posted above on another host, see if it works?
0
 
shahnwebAuthor Commented:
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
 
nizsmoDeveloperCommented:
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
 
wildzeroCommented:
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
 
tkalchevCommented:
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
 
shahnwebAuthor Commented:
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
 
tkalchevCommented:
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
 
a53mpCommented:
I recommend crimsoneditor.com for editing PHP files.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

  • 5
  • 4
  • 3
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now