Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-03-18 06:43:51

Jeremie
Member
From: Provence, France
Registered: 2004-08-11
Posts: 1,578
Website

How to create a one time splash page

I’m looking for a way to create a “one time splash page”. I explain:

when someone go a TXP website frontpage, if it’s his first time and if he is a “real user” (not a spider bot for example) he got a special page, like /welcome. If he is a returning visitor, he won’t see it. So :

  • First time and real visitor : www.site.tld -> www.site.tld/welcome/
  • Returning visitor or not “real” : www.site.tld -> www.site.tld

I’ve googled it, can’t find anything on it. But I’ve seen it on some websites.

The only way I can imagine this to work, would be a javascript code. If a visitor has javascript enabled, we check for a cookie. If he hasn’t got that cookie and we could set one, we redirect him to /welcome. If not (no javascript, can’t se a cookie, already got one) we let him stay on the regular frontpage.

Or maybe this could be done with PHP.

Anyone has any clue about this ? Some code I code use ? (it’s for an Apache setup, mod rewrite enabled, PHP, Perl if needed).

Last edited by Jeremie (2006-03-18 06:44:03)

Offline

#2 2006-03-18 06:53:51

Jeremie
Member
From: Provence, France
Registered: 2004-08-11
Posts: 1,578
Website

Re: How to create a one time splash page

Ok, I got the keywords right this time. I found some things based on javascript, but it’s client side (so it can be delayed), and it will break the back/forward flow.

I’ve been looking for a server side (mainly PHP) solution, but can’t find one. It shouldn’t be difficult:

  1. if user accept cookie
  2. if user don’t have the welcome cookie
  3. then http redirect him to /welcome
  4. else, die

But my PHP is quite rusty.

Offline

#3 2006-03-18 07:31:37

Bastian
Plugin Author
From: Wuppertal, Germany
Registered: 2005-02-02
Posts: 376
Website

Re: How to create a one time splash page

How about mod rewrite by USER_AGENT to www.site.tld/welcome/?
On /welcome you can have a fallback to check for or set $_COOKIE,
that will keep the www.site.tld clean.

Offline

#4 2006-03-18 18:37:19

Jeremie
Member
From: Provence, France
Registered: 2004-08-11
Posts: 1,578
Website

Re: How to create a one time splash page

That might work. If I can find the appropriate rewrite rules, and the PHP checking on /welcome. I’m still a little stuck on the coding part.

Offline

#5 2006-03-18 23:14:48

zem
Developer Emeritus
From: Melbourne, Australia
Registered: 2004-04-08
Posts: 2,579

Re: How to create a one time splash page

It’s actually quite difficult to do cleanly, perhaps impossible, even with cookies.

The problem is, you need to detect users that don’t support cookies, and mark them as such. But how do you flag a non-cookie browser? You need to find a way to distingish between a browser that is visiting for the first time, and a browser that is not a new visitor, but doesn’t support cookies. A test cookie doesn’t help distingish between these two states.

There are ways to do it (check for the IP in the logs, use javascript, use a PHPSESSID flag in URLs), but all can fail; and when they do, you’ll wind up redirecting some poor schmuck around in circles.


Alex

Offline

#6 2006-03-18 23:25:13

Jeremie
Member
From: Provence, France
Registered: 2004-08-11
Posts: 1,578
Website

Re: How to create a one time splash page

An UA doesn’t acknowledge it accept cookies ?

Ok… then what about a test cookie ? Why don’t it work ?

  1. Check the splash cookie
  2. If it’s not found then
    1. Try to set a test cookie
    2. Check that test cookie
      1. If that check cookie is found, redirect the UA and set the splash cookie
      2. If that check cookie is not found, die

No ? What am I missing ?

Last edited by Jeremie (2006-03-18 23:29:49)

Offline

Board footer

Powered by FluxBB