I am trying to build a notification system using PHP session variables ($_SESSION).
My concept is the following:
1 - Loop in a structure field to count the fields within
2 - Store resulting number in a session variable [‘alllogs’]
3 - Set [‘newlogs’] equal to [‘alllogs’]
4 - Display [‘newlogs’] as ‘n notifications’
5 - Vewing the notifications will set [‘readlogs’] equal to [‘alllogs’]
6 - After event, unset all variables except [‘readlogs’]
7 - If new content is added [‘newlogs’] equals [‘alllogs’] - [‘readlogs’]
8 - Display [‘newlogs’] values as ‘n notifications’
Everything is working fine both locally and remote. BUT:
- When the page is visited (session started) in another computer, I got notifications again for the session started in MY computer.
I know it has something to be with the logic I’m using. Initially I thought that PHP were not using cookies for sessions, but it is.
What I need is either Ideas on how to fix this, or even better, how to tie the notifications to the user instead of session. Somehow add the values in a field on the page and compare it? It is possible to write/modify a field value directly from the page?
Any feedback is appreciated.