Jump to content

[SOLVED] Session problem


aktell

Recommended Posts

Hi there,

 

I'm doing code out of a book to learn and I have a small problem !

My app. is working perfectly well, just as I go through it at some stage there is a msg comming up, and that on several pages which use the session id. I like to mention that the page shows perfectly well, just on top this msg.

 

Warning: session_start() [function.session-start]: 
Cannot send session cache limiter - headers already sent 
(output started at /home/../../../auth_user.inc.php:2)
in /home/../..//auth_user.inc.php on line 3

 

The session code is below: On a Php page called auth_userinc.php.

<?
session_start();
if ($_SESSION['user_logged'] == "" || $_SESSION['user_password'] == "")
{
$redirect = $_SERVER['PHP_SELF'];
header("Refresh: 5;
URL=user_login.php?redirect=$redirect");
echo "You are currently not logged in, we are redirecting
you, be patient!<br>";
echo "(If your browser doesn't support this, <a
href=\"user_login.php?redirect=$redirect\">click
here</a>)";
die();
}
else {}
?>

 

Thanks in advance aktell

Link to comment
https://forums.phpfreaks.com/topic/38387-solved-session-problem/
Share on other sites

In PHP the session_start(); header must be the first line after the <?php tag. Meaning if it's included on another file it must be the first line.

 

<?php
session_start();
//remove that from that file
include('auth_userinc.php');
?>

 

Hi there,

Thanks alot, I found that the Session was not included in two pages and the one was as you said I got them working.

Thanks again aktell

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.