Jump to content

setting counter back to date('z')


dekonstruct

Recommended Posts

I'm having problems setting $_SESSION['dailies'] back to the date when it gets to 0.

Here's my code:
[code]<?php

session_start();

$date = date('z');

###counter###

if(isset($_SESSION['counted'])){
$new = $_SESSION['counted'] - 5;
$_SESSION['counted'] = $new;
}else {
$_SESSION['counted'] = 0;
}

#########

### supposed to set counter back to date ###

if ($_SESSION['dailies'] <= 0) {
$_SESSION['dailies'] = date('z');
}

else {
$_SESSION['dailies'] = $date + $_SESSION['counted'];
echo $_SESSION['dailies'];
}


?>

[/code]

I think it might have something to do with the placement of my if statement in the code but I've tried it both before and after the counter function. BAH!

Any help and I'll love you forever. (in a non brokeback kind of way).


Link to comment
Share on other sites

I first define $_SESSION['dailies']; in the else part with:
[code]$_SESSION['dailies'] = $date + $_SESSION['counted'];[/code]

It's so that when the page first loads it's at 0 and when it refreshes it counts down from the day. If there's a better way to do it I'm all ears, it feels like an ineloquent solution but I'm still learning obviously.

Thanks!
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.