Jump to content

[SOLVED] Session Problem


ballouta

Recommended Posts

Hi

It is my first session test. Everything was working properly as expected, I took a break and now the same pages and the same code is not working, i couldn't discover where the problem exists.

 

here's the session code from the first page:

<?php
session_start();
$user=$_POST['user'];
$pass=$_POST['pass'];

$_SESSION['username'] = "$user";
echo $_SESSION['username'];
?>

 

i am able to see the username after the echo command. in this page i do not have any problem.

 

Page 2:

 

<?php

@session_start();
include('CMS/global.inc.php');
$user =$_SESSION['username'];
echo "User = $user";

if($_SESSION['username']) {

here i have some DB code
}
else
{
echo "session not working";
}

 

I cant see the user echoed here and 'session not working' appears.

where's the problem?

please help

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

thank you all

 

First, I didn't close the explorer while making my test.

Second, I removed that @ and I got this warning:

 

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output

started at /home/ballouta/public_html/login.php:7) in /home/ballouta/public_html/login.php on line 28

 

Third, in page2.php I got this warning too:

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/ballouta/public_html/credits.php:7) in /home/ballouta/public_html/credits.php on line 38

 

Note: I just tested the pages again and the result (except the warnings) is correct,

BUT when i upload page1.php and page2.php to another host, it is not working.

 

How do I fix the problem mentioned in the warning so i can get to the secnd part?

 

How do I fix the problem mentioned in the warning
Simple, read the warning messages and find what the output is that they are telling you is occurring in each of the files -

 

output started at ..../login.php:7 (line 7)

 

output started at ..../credits.php:7 (line 7)

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.