Fuxi
Fuxi

Reputation: 7599

php, jquery pagination, storing current page

i'm having a shop system which is displaying articles using a jquery slider plugin, so there's pagination. i'm having an item with record id 123 on "page" 3 - that item has a unique modrewrite url like www.domain.com/myitem-123.html the problem: when displaying the article details i need to somehow store the current page of the slider plugin in order to jump back to the last page of the slider.

i wouldn't like to modify my modrewrite url as it wouldn't be unique anymore (there would be different urls for same item) - the only idea i'm having is using a php session, but i'd need to set it via ajax command on each click which doesn't seem very elegant to me ..

any suggestions?

Upvotes: 0

Views: 293

Answers (1)

tXK
tXK

Reputation: 712

I believe a better and easier approach is to simply store that page number in a cookie and retrieve it on the slider/listing page.

But if you want to get on with your idea and need an improvement, I'd suggest to store the page number in a global variable in JavaScript and only make that request to the server right before the user jumps to the product's page ( you actually have to do it synchronously since the user is closing the page and the request can't "sit" in the background )

window.onbeforeunload = function() {
     // do your server request here to store the $_SESSION['slider_page_no']
} 

Upvotes: 1

Related Questions