The PHP Logic For Displaying Posts While You Are Not on the Site

Hi, We may want to show users what is shared on the site while they are offline in some of our projects.

First of all, we check the cookies for each section at the first entrance to the site.

<?php

if (!isset($_COOKIE['news'])){
    setcookie('news', date('Y-m-d H:i:s'), time() + (60 * 60 * 24 * 30));
}
if (!isset($_COOKIE['question'])){
    // created
}

Then we look to see if any new content has been added to the site since the cookie's expiration date.

In the next login of the user, for example, after 2 days the cookie is already created, so we can show how many new content is available within 2 days.

When the user enters the relevant field, for example, if user clicks on discover, now we change the user's cookie with whatever the current date is, so the last date user sees it is synchronized with that date and nothing is shown because there is no new content.

Comments

There are no comments, make the firs comment