Jump to content

Either ive done something wrong or Sessions are doing it...[SOLVED]


AbydosGater

Recommended Posts

Hi, For my members area..
I have a header file that contains...
[code]
<?php
if (!$_SESSION['user']){
header('Location: http://www.shadowfleet.info');
exit;
};
if ($_SESSION['user']['banned'] == "1"){
unset($_SESSION['user']);
header('Location: http://yourbanned.com');
exit;
}
?>
[/code]
Thats just the important bit...

And it works great fine works perfeck on all my proteced pages..
But i made a members list today with...

[code]
<?php
       echo" <table width='100%' border='0'>
          <tr>
            <td><div align='center'><font color='#FFFFFF'><strong>Member Id</strong></font></div></td>
            <td><div align='center'><font color='#FFFFFF'><strong>Rank</strong></font></div></td>
            <td><div align='center'><font color='#FFFFFF'><strong>Username</strong></font></div></td>
            <td><div align='center'><font color='#FFFFFF'><strong>Profile</strong></font></div></td>
          </tr>";
$query = "SELECT * FROM sf_users ORDER BY member_id ASC";
$result = mysql_query($query);
while($user = mysql_fetch_array($result)) {
$member_id = $user['member_id'];
$rank = $user['rank'];
$username = $user['username'];
echo "

  <tr>
            <td><div align='center'><font color='#FFFFFF'>$member_id</font></div></td>
            <td><div align='center'><font color='#FFFFFF'>$rank</font></div></td>
            <td><div align='center'><font color='#FFFFFF'>$username</font></div></td>
            <td><div align='center'><em><font color='#FFFFFF'>Comming Soon</font></em></div></td>
          </tr>

";
};
echo "</table>";
?>
[/code]

And it works.. But if your on that page, and you go back to another protected page, the sessions gone.. and it redirects you to the homepage...

This is being done on a non banned account, and im logged inworking fine on the rest of the files, but this page is unsetting the session...

Has anyone any ideas?

Please help me!
Ive been reading through the code... Its grand. it works fine with every other page... but this one.. why the hell is it unsetting the session?

Its running both of the If statments when it shouldnt.. the users not banned... and the session['user'] IS set...

It shouldnt be unsetting the session.. and it shouldnt be redirecting to the the index..

Anyone understand whats happening?
Ok i have put that in.. Just after i require the header file... and yes.. it echoed my session information as an array...

This is all after the part for unsetting the session (Even though this part should not be run) But i dont think it is.. If it was unsetting the session in the header file... why would it display the info after?

And still its being unset because after that i refreshed the page and it went back to the index :(:(

Somethings very wrong.. because then my browser crashed and only that window closed:P i dont know whats happening
OK... Ive been here over 2 hours sitting only got up once trying to get this fixed..

And i have finally realised that the problem exists in my code that is calling the members list.. as when i commented it out... everything worked fine no problems

The code is as follows...
[code]
<?php
       echo" <table width='100%' border='0'>
          <tr>
            <td><div align='center'><font color='#FFFFFF'><strong>Rank</strong></font></div></td>
            <td><div align='center'><font color='#FFFFFF'><strong>Username</strong></font></div></td>
            <td><div align='center'><font color='#FFFFFF'><strong>Profile</strong></font></div></td>
          </tr>";
$query = "SELECT * FROM sf_users ORDER BY member_id ASC";
$result = mysql_query($query);
while($user = mysql_fetch_array($result)) {
$member_id = $user['member_id'];
$rank = $user['rank'];
$username = $user['username'];
echo "

  <tr>
            <td><div align='center'><font color='#FFFFFF'>$rank</font></div></td>
            <td><div align='center'><font color='#FFFFFF'>$username</font></div></td>
            <td><div align='center'><em><font color='#FFFFFF'>Coming Soon</font></em></div></td>
          </tr>

";
};
echo "</table>";
?>
[/code]

Anyone see why that code would kill a session?


EDIT:: Ok ive just realised that im using $user['']; to store the information.... DUHHHHH thats what im using for the session $_SESSION['user']; is the user info.. ive had problems like this in the past.. is it cause the vars are the same??

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.