I have to maintain a count of the number of users that has been logged in. Is there any way in PHP to do it without using database or creating a file to store details ?
No framework used, just simple plain PHP.
I have to maintain a count of the number of users that has been logged in. Is there any way in PHP to do it without using database or creating a file to store details ?
No framework used, just simple plain PHP.
Your options are literally, a data store or a file. You could alternatively offload them to some remote server which does something or find some sort of "remember some data" third party API, but realistically it needs to be a data store or a file.
Files would be kinda slow at this and you would get race conditions, so you'd be right to avoid those.
A MySQL Database or the like is possibly also overkill if you are not currently using one.
Another option (as @shatheesh pointed out) is Redis.
I would suggest you do that. :)
You can achieve this using a session variable and storing count in same.
For further understanding you can visit this link :