This is quite a common situation, we have a search form which leads to a result page. The number of found results can be big enough to require pagination. If we use the classic pagination code, the posted parameters will be lost when changing page and our search gets broken.
There are several ways to solve the problem, as tux21b wrote in this stack overflow answer.
Here I will talk about the first method, using session.
In the same stack overflow page you can see an answer by rvnovaes, which surely works but in my opinion has some eliminable drawbacks. The first is that if there are many search fields the code we have to write is too long (yes ...