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!
Link to comment
Share on other sites

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?
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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