Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Basic session variable help – create session to enable background onload

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #171237
    matthisco
    Participant

    Hi Folks,

    I’ve got this basic php

    session_start();
    if (!isset($_SESSION['backgroundLoad'])) {
      $_SESSION['backgroundLoad'] = 0;
    } else {
      $_SESSION['count']++;
    }
    

    Which I would like to use in jquery to fade in the background when the site has first been visited only.

    Here is my jquery:

    #background {
        background-image: url("images/mega.png") !important;
        background-position: center bottom;
        background-size: cover;
        height: 100%;
        opacity: 0;
        width: 100%;
    }
    var loadit = <?php echo $_SESSION['backgroundLoad']?>;
    if (loadit == ""){
     $("#background").delay(1000).animate({"opacity": "1"}, 100);
    }
    

    When I click on different links, the background still fades in on all pages, can anyone please help?

    Thanks

    #171256
    __
    Participant
    session_start();
    if (!isset($_SESSION['backgroundLoad'])) {
      $_SESSION['backgroundLoad'] = 0;
    } else {
      $_SESSION['count']++;
    }
    

    backgroundLoad will always be 0. You never increment it.

    I would also suggest comparing loadit to 0 (instead of ""), since that’s what you’re actually passing to it.

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘Back End’ is closed to new topics and replies.