Jump to content

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)

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.