Marking the latest news as ... "new"

On some websites or forums that I usually browse, posts I haven’t read yet are marked as “new.” I would like to implement this function on the website that I developed (from time to time from time to time) - php / mySQL. How is this usually done? Do you need a cookie that remembers the last date / time of the visit? Or the last viewed posts / URL? How can I identify users?

+3
source share
5 answers

Cookies are just one of the possible ways to identify a user for a session or between visits without authentication. Although this is a very common and useful way. (PHP may also use sid or another parameter, although it is no longer common.)

You need to save those threads / messages that the user has read, or which he / she does not have. You can summarize everything by reading everything up to the "date" or postId for specific subforums.

, , . , , , , (x )/ ( y , -, z , admin) .

: CSS , , / .

+3

: : ( URL-), . , reset, , cookie, cookie ( " ", , reset )...

url ( ) , , , .

EDIT: CSS .

+3

Cookie - .

, , , , 1 , cookie .

, , .

0

cookie, cookie , . , .

0

:

  • , .
  • , / , .
  • If the user’s date / time is within the last ten minutes, I do not update the user’s date / time.

Here is my code ...

function drawPage
    if (isLoggedIn) 
        get dbUser from database
        lastUserDateTime = dbUser.LastCommentTime
    else 
        lastUserDateTime = yesterdaye
    end if

    for each post
        get date of post 
        if post->date < lastUserDateTime mark it as new
        draw the post
    loop

    if (isLoggedIn) 
        if (lastUserDateTime + 10 mins) < now 
            dbUser.LastCommentTime = now
            update dbUser in database
        end if
    end if
end function
0
source

All Articles