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
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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.