NameSilo

Welcoming Page Load Question

SpaceshipSpaceship
SpaceshipSpaceship
Namecheap AuctionsNamecheap Auctions
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
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
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
Close
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
Close
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
Close
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
Close
Add to rep, maybe? :blink:
 
0
Close
No problemo
 
0
Close
cooool thanks COMPUXP !
 
0
Close
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
Close
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
Close
Still isn't working...
Any other ideas?
 
0
Close
your testing it on your own server(your own pc ) or with a host ?
 
0
Close
What?
 
0
Close
Appraise.net

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Filters for activity feeds
Your news feed, Latest activity, and the activity tab on profiles now have filter buttons: All, Posts, Quick replies, and Other. Your...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back