Howdy, didn't turn up any search results relating to this, so I apologize if it is a repeat. I'm a little hung up on how to implement this, so maybe ya'll can help me out. I'm looking for a way to display a splash screen to visitors (which is basically just a banner image) and when they click on it to enter the site, it creates a cookie to expire in 1 day. The meaning of the cookie is so that anytime they go back to the root of the website, they won't have to be nagged with that splash over and over. So basically what I have right now is my main index file that is the front of the website, and the splash screen file (both PHP extensions). I'm a little rough on php and cookies, so that's why I'm having a difficult time. Also, I need a way for visitors with cookies disabled to just skip the splash screen. Many thanks for any advice. If you need further clarification, let me know and I'll try my best. - AP
Just as a point of note, the last script I tried using was a Password Protect thing from zubrag.com, modified so that the username/password were auto-added as values to the form and the display was an image input. Problem with it was that it wouldn't work in IE. Would just keep refreshing the page. Most of our visitors are all IE-based, so need to accomodate them as best I can. Much obliged. (ZubRag script: http://www.zubrag.com/scripts/password-protect.php)
Why not have your splash screen in index.php then use something like home.php as the main home page? That way you have the benefit of users being able to bookmark the home.php (no need for that cookie)
That would be all well and good, except the whole site is already made up and the "Home" links already are pointing to the root index.php file on the server. It would just be a temporary thing for the holidays (holiday splash banner for a little flare), so I really don't want to have to update links on however many pages I have (don't even know anymore). Anyways, I think I've worked it out using that original script I talked about, just had to do some re-work and examination. I'm still open though to any further advice you might have should this not work. Mainly because that script relies on the usage of the UN/PW fields to work (even though I can set the inputs to hidden with the correct values). I'd just prefer a less convoluted means without having to jump through hoops. Thanks!
I would do it like this: You say you don't want to switch round the names of your pages, so, on your index.php page, at the very top, add this piece of code: <?php if(!isset($_COOKIE['no_splash'])) { // Start of the IF statement - if the user does not have a cookie that says whether he/she has visited the splash page, take them to the splash page header('Location:http://www.yoururlhere.com/splash_page.php'); // Redirect code } else { // But... if they do have the cookie (they have been on the splash page), just serve the page as normal //.... do page here } PHP: And, for the splash_page.php script, <?php $expire = time() + 60*60*24; // This means, expire in 1 day - 60 seconds * 60 minutes * 24 hours setcookie("no_splash", "1", $expire); // This makes the cookie. It goes in this order: setcookie(cookie_name, cookie_value, expiry_time) // Do splash page from here down.... ?> PHP: Instead of checking whether the cookie is present, you could have the code on the index.php page check for a certain value of the cookie by using: <?php if($_COOKIE['no_splash') == 'Value')) { // Do code here } ?> PHP: Hope that helps!
You could use javascript to create a cookie if it doesnt exist, if it exists, set the css of the banner to display:none So the banners always there.. its just invisible if the cookie exists.. To check if the visitor has cookies enabled, Create another temporary cookie, check soon after if it was created, If not then dont display the banner.. ! Hope what i said makes sense..