Saving needed only when session change

Saving needed only when session changes, otherwise session do save on any page load (why if its not changed?). 
I think setTimeout can be replaced. 

Sorry for my bad english ;)