Jump to content

Can i set a session on a page?


virtuexru

Recommended Posts

Like say I want to update a page that has a countdown on it for a number... The max for that number is 800 for instance.. I set that to be the maximum, then if the number on the page is less than that, I can add 100 every 30 minutes until it is equal to or greater than 800.

 

How would I go about doing this in PHP without having to manage the page after I set the initial maximum?

Link to comment
Share on other sites

I don;t know exactly what you are asking but I cooked something up quickly.

 

session_start();
if(isset($_SESSION['number']) {

    // do some checks and do other things
    $thirtyMins = 60*30;
    if(isset($_SESSION['last']) AND time() > ($_SESSION['last'] + $thirtyMins)) {

        // update the last and number sessions

    } else {

        // no last done set the last session and do the first action to the number

    }

} else {

    // no session and do something else

}

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.