LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-22-2004, 08:08 PM   #1
manikantha
Member
 
Registered: Sep 2004
Location: Guntur,India
Distribution: FC3 - 64-Bit
Posts: 56

Rep: Reputation: 21
"$_SESSION is showing some error in PHP"


Hi all,

I am using sessions to develop a php page. But it is showing the following errors....


Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /var/www/html/Project/existing_user.php:2) in /var/www/html/Project/existing_user.php on line 2

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /var/www/html/Project/existing_user.php:2) in /var/www/html/Project/existing_user.php on line 2

And this is the code which I have written in existing_user.php

<?php

session_start(); /*Showing Error Here*/

$login=$_POST("Login"); /*Which I am getting from before page */
session_register('login');
$_SESSION('login')=$login;

?>

Could any one please help me!!
 
Old 09-22-2004, 09:24 PM   #2
CroMagnon
Member
 
Registered: Sep 2004
Location: New Zealand
Distribution: Debian
Posts: 900

Rep: Reputation: 33
Do you have any whitespace (or anything) before the <?php tag?
 
Old 09-22-2004, 10:00 PM   #3
manikantha
Member
 
Registered: Sep 2004
Location: Guntur,India
Distribution: FC3 - 64-Bit
Posts: 56

Original Poster
Rep: Reputation: 21
hi CroMagnon,

ThanQ U for your advice .. I have not seen that there is a new line before <?php tag ... and it is now working after removing it.

I have one more doubt can U please help me...

In the above file I have stored the login in $_SESSION('login') .........

But in some other file I am not able to retrieve it...

ThanQ U
 
Old 09-22-2004, 10:13 PM   #4
CroMagnon
Member
 
Registered: Sep 2004
Location: New Zealand
Distribution: Debian
Posts: 900

Rep: Reputation: 33
Hmmm... are you calling session_start() in your other file?
 
Old 09-22-2004, 10:17 PM   #5
manikantha
Member
 
Registered: Sep 2004
Location: Guntur,India
Distribution: FC3 - 64-Bit
Posts: 56

Original Poster
Rep: Reputation: 21
ya!! I am.. and one more thing is that when I am checking with

if(isset($_SESSION['login']))
echo ("YES\n");
else
echo("NO\n");

It is printing NO
 
Old 09-22-2004, 10:46 PM   #6
HappyDude
Member
 
Registered: Jul 2003
Posts: 140

Rep: Reputation: 15
shouldnt it be:

if(isset($_SESSION['login'])) {
echo ("YES\n");
} else {
echo("NO\n");
}
 
Old 09-22-2004, 10:47 PM   #7
manikantha
Member
 
Registered: Sep 2004
Location: Guntur,India
Distribution: FC3 - 64-Bit
Posts: 56

Original Poster
Rep: Reputation: 21
ya!! Sorry I have given like that only.......
 
Old 09-22-2004, 11:08 PM   #8
CroMagnon
Member
 
Registered: Sep 2004
Location: New Zealand
Distribution: Debian
Posts: 900

Rep: Reputation: 33
Either of those will work, as long as there is only one statement in the if block. But it's better to use the braces anyway, since you can add more lines later.

I used this code:

(test1.php)
Code:
<?php
session_start();
$login = "CroMagnon";
session_register("login");
?>
<html>
<body>
<a href="test2.php">Test!</a>
</body>
</html>
(test2.php)
Code:
<?php
session_start();
?>
<html>
<body>
<?php
if (isset( $_SESSION["login"] ))
        echo "YES!";
else
        echo "Problems!";
?>
</body>
</html>
and this worked fine for me. Perhaps you can compare it with your code and see where the difference is (I haven't posted my username from a form, but that shouldn't matter).
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
k3b: "error decoding audio tracks" and "could not unlock cd driver" lefty.crupps Linux - Software 7 10-13-2005 11:29 AM
"mythtv-setup" giving "Session management error: Authentication Rejected" Mitchua Ubuntu 0 10-09-2005 04:32 PM
FC4 install errors, "diabling IRQ #10" "nobody cares" error message??? A6Quattro Fedora 6 07-20-2005 12:49 PM
LFS 4.1: Stalled at Perl, "missing seperator" error from "make" SparceMatrix Linux From Scratch 1 06-07-2003 03:31 PM
php ide with "break" and "trace" Kayaker Programming 3 04-25-2003 02:52 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:43 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration