How to use session.state in slider

I have 3 pages, the slider is on page 2, if I go to page 1 or 3 then I return to page 2 then the slider will reset. how to use session.state in slider?