I have 2 files as follows:
index_en.php
- Code: Select all
<?php
session_start();
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Title in English</title>
</head>
<body>
<?php
echo "Session ID: " . session_id();
?>
</body>
</html>
index_vn.php
- Code: Select all
<?php
session_start();
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Tiêu đề bằng tiếng Việt</title>
</head>
<body>
<?php
echo "ID của session: " . session_id();
?>
</body>
</html>
I wrote both files using notepad. The first I saved as ASCII encoding text file, the second saved as UTF-8 encoding text file. When loaded in browser, the index_en.php is fine, but the index_vn.php gave these warning:
- Code: Select all
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\xampp\htdocs\test\index_vn.php:1) in C:\xampp\htdocs\test\index_vn.php on line 2
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\xampp\htdocs\test\index_vn.php:1) in C:\xampp\htdocs\test\index_vn.php on line 2
Also, the index_vn.php created different session ids every time I reload the page, that's odd.
I uploaded these two to a host and they run correctly. You can see these pages here:
http://troyvn.byethost31.com/temp/index_en.php
http://troyvn.byethost31.com/temp/index_vn.php
I think this problem may be caused by settings in php.ini, but I don't know how to correct it. Anyone has any idea?