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
Popular Articles
Popular Tags
- #directive
- #Function
- #Json
- #Class
- #SASS
- #Form
- #Redirect
- #API
- #Special Characters
- #Special
- #Random
- #Generating
- #
- #Text
- #Ajax
- #URL
- #Encrypting
- #React
- #Show
- #timeAgo
- #PSR-4
- #Hide
- #DDOS Protection
- #DDOS
- #cURL
- #Logic For Displaying Posts
- #Error
- #Key
- #General Error
- #1364 Field
- #Abbreviation
- #Blade
- #Version
- #QR
- #QR Code Generating
- #Array
- #Arrays with Key Values to String Statement
- #Short Tag
- #Activate
- #Real Time
- #Socket.io
- #301
- #Custom Directives
- #Iframe Detection
- #Date
- #Characters
- #Insert
- #Autoloader
- #Composer
- #Reading
There are no comments, make the firs comment