Jump to content

$session gets lost


eutervogel
 Share

Recommended Posts

Hi,

On my website the user is able to choose between to styles of a gallery. A gridview and a stripe view.

I want to store the choice during the whole session. 

So if the user chooses a style I do it like so:

$query = $_GET['view'];
    if($query){
        $session->set('view', $query);
    }

So that's working pretty fine, but after a random number of menuclicks or reloads its gone. Sometimes it is stored for 10 -15 pageloads and sometimes it's gone after 2 loads,

Lifetime is set to 3600 in php.ini

session.gc_maxlifetime = 3600

 

This is how I look if it exists:   

 if($session->view == 'grid'){
        include('album-grid-title.php');
        $session->set('view', $query);
    }
    elseif($session->view == 'stripes'){
        include('album-stripes.php');
        $session->set('view', $query);
    }
    else{
        include('album-stripes.php');       
    }

 

Can anyone point me in the right direction and tell me what I'm doing wrong or why $session gets lost?

 

Thanks in advance

Link to comment
Share on other sites

Welcome to the forums @eutervogel.

I have no idea why the sessions are disappearing. Sessions should also work for guest (aka not logged in users). Just want to suggest an alternative; cookies? Also, is it necessary to conditionally load the grid versus stripe views? Sometimes I find it easier to just load both views and using CSS and JS hide/show the views as per user request.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...