Jump to content

Session cache delimiter error


konrad00

Recommended Posts

Hi everybody!

I just started php coding and come across a problem while creating website for my coursework.

I have used code from

http://php.codenewbie.com/articles/php/1482/Login_With_Sessions-Page_1.html

My goal is to have main page index.php with login link on the top. If user is not logged, script should show link "Login". If user is logged it should show message like "hello $USER .....".

I added following lines into the header of my index.php.

"

<?php

    include("connect.php");

    include("auth.php");

    include("nav.php");

    echo "This is my home page.";

    mysql_close();

    ?>

"

--------index.php

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

  <head>

    <meta name="generator" content=

    "HTML Tidy for Windows (vers 15 August 2007), see www.w3.org">

    <meta http-equiv="content-type" content="text/html; charset=windows-1250">

    <meta name="generator" content="English language school">

    <title>

      MACDONALDS SCHOOL

    </title>

    <link rel="stylesheet" type="text/css" href="style.css" title="The blues">

<?php

    include("connect.php");

    include("auth.php");

    include("nav.php");

    echo "This is my home page.";

    mysql_close();

    ?> 

 

</head>

  <body>

        <div id="box">

 

.....code ......

    </div>

  </body>

</html>

 

--------index.php ---end

and im getting login form with following error/warning

"

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/konradk/public_html/konrad/webdev/set08101/1/index.php:16) in /home/konradk/public_html/konrad/webdev/set08101/1/auth.php on line 1

"

I can log in and then my page loads.

Can someone help me with two questions:

 

1. how to get rid of this error?

I am aware that if there is no whitespace error dissapears but Im stuck how to get working with my page.

 

2. when user (not logged) goes to index.php he should have main page loaded (index.php) and login form visible, then he should be able to log in and page should reload with new welcome message.

 

Any help would be appreciated

 

Konrad

Link to comment
https://forums.phpfreaks.com/topic/156907-session-cache-delimiter-error/
Share on other sites

From the error message -

output started at .../index.php:16

Everything from line 1 to line 16 of index.php is content that is being output and is preventing the session_start on line 1 of auth.php from working.

 

All headers (session_start() works by sending a header to the browser) must occur before any content is output to the browser. Move your session start to the beginning of your page.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.