|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2002-01-10 15:49 UTC] mchin at apollodisplays dot com
i can't use session, give me an error when use ie 6.
Warning: Cannot send session cookie - headers already sent by (output started at /home/www.apollodisplays.com/public_html/mainpage.php:10) in /home/www.apollodisplays.com/public_html/mainpage.php on line 29
Warning: Cannot send session cache limiter - headers already sent (output started t /home/www.apollodisplays.com/public_html/mainpage.php:10) in /home/www.apollodisplays.com/public_html/mainpage.php on line 29
my code is very simple. see below ---->
session_start();
session_register("userright");
$HTTP_SESSION_VARS["userright"]=$right;
anyone have any idea ? thankx
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 16:00:01 2025 UTC |
baZz at basurto @ canada dot com ============================================================ Hi, I was having the same problem on php 4.0.3, but it is easy to solve. (At least this work for me). First of all let me tell you that this warning is sent because you are trying to start a session that already start. SOLUTION ============================================================ The warning that php sends to you is the following: Warning: Cannot send session cookie - headers already sent by (output started at /home/www.apollodisplays.com/public_html/mainpage.php:10) in /home/www.apollodisplays.com/public_html/mainpage.php on line 29 Warning: Cannot send session cache limiter - headers already sent (output started t /home/www.apollodisplays.com/public_html/mainpage.php:10) in /home/www.apollodisplays.com/public_html/mainpage.php on line 29 The only thing that you have to do is put your session_start(); line within the <head> tags of your html or just before the line 10. Why before the line 10? because the warning tells you that the headers was send in that line. EXAMPLE ============================================================ Here I include a very simple example in order that you test that your php session is working. session_test.php ============================================================ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>Untitled</title> </head> <body> <?php session_start('mysession'); class Cus{ var $cusid; function newCus($cusid, $index){ $this->cusid[$index] = $cusid; } function getCus(&$tmparray){ for($i = 0; $i < count($this->cusid); $i++){ $tmparray[$i] = $this->cusid[$i]; } } } $customer = new Cus(); $customer->newCus("Cliente 1",0); $_SESSION['customer'] = $customer; echo "<a href=\"./session_test2.php\">P?gina 2 de la sesi?n</a><br>"; print_r($_SESSION); ?> </body> </html> session_test2.php ============================================================ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>Untitled</title> </head> <body> <?php session_start(); class Cus{ var $cusid; function newCus($cusid, $index){ $this->cusid[$index] = $cusid; } function getCus(&$tmparray){ for($i = 0; $i < count($this->cusid); $i++){ $tmparray[$i] = $this->cusid[$i]; } } } $_SESSION['customer']->getCus($tmparr); print_r($tmparr); session_unset(); session_destroy(); ?> </body> </html> I really hope that this help you.