Search code examples
javascriptphpcodeignitersplash-screen

Load splash screen only once at start in php


I have already created a splash screen using jquery's fadeOut option. It is working fine but the problem is the screen is loading every time I click to go to next page. I need splash screen only at startup. I think I need to use session or something but I am not able to find the solution. I am using following script.

 $(document).ready(function () {
 $("#splashscreen").click(function () {
    $("#splashscreen").fadeOut(2000); 
 });
 });

Solution

  • This should work:

    $(document).ready(function () {
        if( $.cookie('splashscreen') == null ) { // Here you are checking if cookie is existing if not you are showing a splash screen and set a cookie
            $("#splashscreen").fadeIn();
            $.cookie("splashscreen", 1, { expires : 10 }); // cookie is valid for 10 days
        }
        $("#splashscreen").click(function () {
            $("#splashscreen").fadeOut(2000); 
        });
    });