|
Posted by Chung Leong on 11/16/25 11:28
Bob Bedford wrote:
> In fact the session variable is also used to avoid worring about such GET or
> POST variables.
> Let's explain: the user make a search about a shoe make.
> Then he looks trough the results, changing some pages, going inside articles
> to see details, and so on, then want to perform an other search.
> At every page, I've to worry about 10-20 variables every time. Putting them
> in a session variable, I may ask the variable when needed, without worring
> if I passed between all pages. For this I created a bounch of functions to
> store and retrieve variable very easely, and it's a pain saving as you don't
> forget to pass variables between pages.
Well, the pain of passing variables between pages is less than that of
dealing with session issues. If you bundle the search criteria in an
associative array, appending them to a URL isn't that hard.
I'm mentioning this because I use Firefox's tabs extensively. Given a
list of search results I'd almost inevitably center-click on the items
of interest to view them in separate tabs (so I can quickly jump
between them). Using session for passing variables would lead to very
odd behaviors in this scenario.
> That's the main reason we used sessions variable. We don't need to worry
> about bookmarking such pages, as they are dynamic.
Just because the pages are dynamically generated doesn't imply that
visitors wouldn't want to bookmark them. Also keep in mind that browse
history functions as an automatic bookmarking mechanism. It's quite
reasonable for someone to want to return to a search done on an earlier
day. Having to reenter the 10/20 parameters you mentioned would be
quite annoying.
> I am wrong ? any advice would greately be appreciated.
In programming you usually want to avoid side-effects as much as
possible. You don't want the outcome of an operation to be dependent,
implicitly, on the effects of earlier operations. Passing variable
using sessions mean that the HTTP requests have to arrive in a
particular order. It's not a thing that you should depend on, as you
have no control over the browser or the end-user.
Navigation:
[Reply to this message]
|