Re: Session variable functionality?

"David Jeske" <[email protected]> Sun, 30 Aug 2009 21:08:39 -0000
Newsgroups gmane.text.clearsilver.general
Message-ID <[email protected]>
-- John E wrote:
> Hi,
> Is there a way of sharing some information between all the pages the visitor
> is using on my site for the duration of his visit?

There are several ways to do this. If the data is small, one of the simplest
methods is to use a small temporary cookie.

> For example, if users come from Google, I want to record the search term they
> used to find the site, then, say, display it at the top of the page for all
> pages the user is visiting. Any way to achieve this?

Here is how I would do this:

1) write code that runs in every page to look at the "referrer" URL. If the
referrer URL on any of your pages is google.com, you can parse-apart the entire
URL to find the "q=" paramater, this is the search term they used at Google.
Then, you can take the contents of the "q=" paramater and set it into a cookie
for your own site, "ref_q" for example.

2) On every page of your site, look for the "ref_q" cookie and if it exists,
display it at the top of the page.

#1 will be coded up in your implementation language. What language are you
using along with clearsilver to implement your site?

#2 can be implemented entirely in clearsilver if you wish, by referencing
something like CGI.Cookies.ref_q in your templates.