Storing current CPagination page in session.

I'm currently trying to do the following:

I have a search form that stores POST data in submissions, so that the search listing remembers its "state" when i click into an individual item or another page, and then go back to the list again.

It works well for all the search parameters, but my list is paginated using CPagination component and ideally i would like to store the page in session as well.

Storing the actual value in the session(using $_SESSION and user->setState()) works as expected, but i'm having trouble setting the currentPage with the value from my session. Current code is shown as below:

Ps: I extended CPagination in the class Pagination to make the first page link have ?page=1 as compared to no "page" GET variable, so i can set the Session variable according to the GET variable.

Any ideas what i'm doing wrong anyone?

What is the problem?

I want to store the full state of my search list in session, so if i leave the page and return, as long as the session is still alive, the list should be in the state i left it in e.g. same page, same search parameters etc.

Problem is that i can't get the current page to load from SESSION using the code i appended above. But all other parameters are ok.

You are setting $_SESSION[CLASS][$pages->pageVar] all the time. You should not set it when you want to restore the current page from the session.

I just realised also that i was setting the session variable to 1 all the time if there wasn't any GET page value in my example code.

How embarrassing haha…

It works now. Thanks!