Jump to content

PHP Sessions Problem


Jesper

Recommended Posts

Hey everyone,

 

I'm coding a website and I want to show the contents of a database and sort the records by using ORDER BY in mysql and set it to DESC or ASC. Now to determine wether it has to be ASC or DESC, I store in a session the variable $_SESSION['effect_sort_dir']. I use this code:

 

if (($_SESSION['effect_sortby_dir']=="DESC") or !(isset($_SESSION['effect_sortby_dir'])))
    {
    $effect_sortby_dir="ASC";
    $_SESSION['effect_sortby_dir']="ASC";
    }
else if ($_SESSION['effect_sortby_dir']=="ASC")
    {
    $effect_sortby_dir="DESC";
    $_SESSION['effect_sortby_dir']="DESC";
    }

 

Now I used this for the members list too (variable names had 'users' instead of 'effect'), and it worked perfectly. But for the effects, it just doesn't. Does anyone see what I'm doing wrong, or what in PHP could have caused this bug? I use session_start() before this in an included file using include(file.php).

Link to comment
https://forums.phpfreaks.com/topic/118699-php-sessions-problem/
Share on other sites

Does anyone know what could be the cause? For going to the new sort page I use

<a href='?sort=name' name='sort_name'>Name</a> ·
<a href='?sort=date' name='sort_name'>Date</a> · 
<a href='?sort=rating' name='sort_name'>Rating</a> ·
<a href='?sort=category' name='sort_name'>Category</a> ·
<a href='?sort=downloads' name='sort_name'>Downloads</a>

Link to comment
https://forums.phpfreaks.com/topic/118699-php-sessions-problem/#findComment-611593
Share on other sites

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.