Dynadot — .com Registration $8.99

Welcoming Page Load Question

Spacemail by SpaceshipSpacemail by Spaceship
Watch

zack

Account Closed
Impact
5
Okay.
I want a welcoming page that will load with the websites index URL. I only want it to load once so if a person goes back to the site with the same URL later, the welcoming page won't show (unless they delete history/cookies/tempfiles,etc).

Does anyone know how I can accomplish this?
 
Last edited:
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
Well, if they accept cookies and don't delete them, set a cookie with PHP. Then, try and detect the cookie. If it's there, then use the PHP header() function to redirect to the actual content (past the welcome page).

If you DON'T want to use PHP, Javascript MAYBE able to do this, but they'd have to have JS enabled and history not cleared... and that only lasts about 7 days usually anyways. PHP cookies is your best bet, I think.
 
0
•••
That sounds good. Do you have a link showing me how to do this? Or an example of something similar. I'm new to php and cannot right my own code in javascript (only mod hehe). Thanks for your time btw.
 
0
•••
No problem.

Put this at the top of your welcome page (this must be the FIRST thing! Before ANYTHING is sent to the browser):

PHP:
<?php

if (isset($_COOKIE['visited']))
{
    header('Location: go_to_this_page.php');
}
else
{
    $expire = 60*60*24*7*52;
    setcookie('visited', 'yes', $expire, '/', '.yoursite.com');
}
?>

That should set a cookie that expires after 1 year. (Those numbers are in seconds).

Now, you need to edit that code a bit:
  • You may change the cookie name if you wish, but be sure that you change it in both spots
  • Edit 'go_to_this_page.php' in the header() statement to the page you want to redirect to. Can also be a URL.
  • Change '.yoursite.com' to your site's domain. Keep that period as the first character so the cookie will be recognized under all subdomains

Hope that helps :)
 
0
•••
Wow. This looks brilliant! Thanks a bunch for the help. :blink: If there's anything I can do for you don't hesitate to ask.
Have a good night.
 
0
•••
Add to rep, maybe? :blink:
 
0
•••
No problemo
 
0
•••
cooool thanks COMPUXP !
 
0
•••
Ok I'm missing something.
Check the attatchment for a screenshot of the code.

Do I need a .txt file for the php to read?
Did I put the code where I shouldn't have?

My main page is named "index2.htm" now.
THe welcome page is named "index.htm"

It still continues to goto the welcome page after one visit.
 
0
•••
Ah, yes, sorry - forgot that. Rename the file so that it has a .php extention. Then it will work.

EDIT: No it won't. Lol... sorry :) Put the PHP code FIRST THING on the webpage. Even before the <html> tag.
 
0
•••
Still isn't working...
Any other ideas?
 
0
•••
your testing it on your own server(your own pc ) or with a host ?
 
0
•••
What?
 
0
•••
Appraise.net

We're social

Unstoppable Domains
Domain Recover
NameMaxi - Your Domain Has Buyers
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back