/    Sign up×
Community /Pin to ProfileBookmark

Redirect only once

I have created a new page which should replace an old one.
The old one is in “/” and the new one is in “/v2/”.
I don’t want to change this and I don’t want to redirect always to the new page because then the content from the old page is not accessible anymore.
How can I achieve that a visitor will be redirected only at the first time of his visit (for 24 hours) with PHP?
Thanks

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@aj_nscNov 24.2009 — http://ca2.php.net/manual/en/function.setcookie.php

Set it to expire in 24 hours.

When a visitor visits your site, check to see if this cookie exists, if it does then load up the old page, if it doesn't then set it and load up the new page.

Don't forget to obey the cookie rules when setting a cookie - setcookie() can only be called BEFORE the browser receives any content (including whitespace) from your script.
×

Success!

Help @DaSilva spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...