Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums

Go Back   Code Forums > Application and Web Development > PHP

Reply
 
LinkBack Thread Tools Display Modes
Old 06-17-2004, 06:27 PM   #1 (permalink)
learntophp
Registered User
 
Join Date: Jun 2004
Posts: 1
learntophp is on a distinguished road
session_start(): Cannot send session cookie

PHP 4.3.6

Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /web/htdocs/htdocs/index.php:1) in auth.php on line 2

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /web/htdocs/htdocs/index.php:1) in auth.php on line 2
You are not authenticated. Please login.


Are the errors I am gettting usin ght efollowing code:

<?
session_start();
include ("connect.php");

// convert username and password from _POST or _SESSION
if($_POST["username"])
{
$username=$_POST["username"];
$password=$_POST["password"];
}
elseif($_SESSION["username"])
{
$username=$_SESSION["username"];
$password=$_SESSION["password"];
}

// start and register session variables
session_register("username");
session_register("password");

// query for a user/pass match
$result=mysql_query("select * from users
where username='" . $username . "' and password='" . $password . "'");

// retrieve number of rows resulted
$num=mysql_num_rows($result);

// print login form and exit if failed.
if($num < 1){
session_destroy();
echo "You are not authenticated. Please login.<br><br>
<form method=POST action=index.php>
username: <input type=text name=\"username\">
password: <input type=password name=\"password\">
<input type=submit>
</form>";

exit;
}
?>
-------------------------------link_1.php

<?
include("auth.php");

// begin content
include("nav.php");

echo "This is my home page.";
?>

Any ideas on how the fix this?
learntophp is offline   Reply With Quote
Old 06-17-2004, 07:55 PM   #2 (permalink)
joe_bruin
LOAD "*",8,1
 
Join Date: Feb 2003
Location: la.ca.us
Posts: 254
joe_bruin is on a distinguished road
remove the empty lines and white-space before the "<?" at the beginning of your files.
joe_bruin is offline   Reply With Quote
Old 06-18-2004, 07:51 AM   #3 (permalink)
sammy
Code Monkey
 
sammy's Avatar
 
Join Date: Jun 2004
Location: Brooklyn/Rochester
Posts: 53
sammy is on a distinguished road
Send a message via AIM to sammy
If you read the error message, it says that index.php has already sent the headers to the client. Im guessing your doing an include in index.php to include this file you are using. If you are, then you need to remove any print statements before the include statement in index.php .
This is why I dont have too many linked includes. Gets messy
__________________
sammy is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
check if session variable is null? sde Java 3 07-07-2004 12:27 PM


All times are GMT -8. The time now is 01:41 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting