Count the amount of users that are logged in [closed] - php

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I am working on a school project. The assignment is to recreate our own version of Ebay. A requirement is to display the number of logged in users. What is the best way to do this? We are using PHP.
We are using a database so we could save the amount of loggins there but there is no proper way to decrease this amount since people often just leave the site without logging out.
Some suggestions would be awesome!

you could have a heartbeat script that updates a datetime on the user column.
and the show logged in users script could get all logged in users with time < 5 mins

Related

Online voting system in php [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
My project is online voting system in php, requirements is that one user votes, So he will be able to vote only then after 4 years.
Sessions gonna work ?
No. Sessions only last as long as the browser remains open.
A better idea would be to post the data to a database with a timestamp. Then, when the user tries to vote again, the most recent vote timestamp by that user is drawn from the database.
If the most recent vote timestamp is > 4 years old, you can then allow the user to post again.

How can i create a page that tailors personal info to the user [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
After hours of trial and error, using WAMP i made a login system that mails me locally ( password recovery etc). I want to make pages that only the user has information tailored to the user, think of it as a profile page Facebook or Twitter, the news updates.
You can use sessions. In php you can type session_start(), then you can store some information about the user. So if the user don't have a session he can't access the page. Search about session_start(). You will find many examples about it.

How to limit the number of active sessions a user can have [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am buiding a licence style system where a user can buy one or a number of licences. They can then log in to the system only once with each licence (similar to Spotify). So a user buys 2 licences. They can log in once in Firefox and once with Chrome. If they try to log in using IE the system will prompt/warn that they will be logged out of another session.
I understand a user could just use multiple instances of the same browser to gain access to multiple sessions/screens but thats fine. We are really only trying to stop users from using multiple devices (2+ separate PCs) if their licence restricts.
Any idea how I would go about this? Can I check session data from another instance or should I store the logins in a separate table and check against that?
Thanks

Know Time a visitor stays on website [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
i want to know how much time a visitor stays on my website..??? can it be done with any online services ??..Any help would be appreciated..
Use Google analytics http://www.google.com.au/analytics/
A session can only change every time you call set or reset it.
But if you wanted to, you could use jQuery ajax, to run a script every X seconds or mins. Then in the file that you are ajax'ing in. Change your session data.
You will find analytics make a new request every time the user does something. Like moves the mouse, clicks on something, etc. So you would have to set up some js to do that as well.

How do I display all users visiting a webpage? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Not sure if this is too open-ended of a question for StackOverflow but, I'm trying to make a basic chat client using AJAX, php and mysql. Users can send messages to the chat, but they can't see which other users are in the chat. Is there a good way to track which users are viewing a webpage and which have left?
the simplest solution is to have a database that records sessions, or at least a "last logged in" column in your database. once a user has logged in, it should reflect in the database that he or she has logged in using a time stamp. this session should auto expire in a given amount of time (like say auto logout, or in others the "idle" status)
then have an AJAX "heartbeat" to check the database if that user has logged out or expired or idle as well as return a list of un-expired users.

Categories