How do I display all users visiting a webpage? [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 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.

Related

Count the amount of users that are logged in [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 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

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

Showing users specific files [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I have built a login application (App), and I'm thinking of implementing another feature.
I want to show users specific content depending on which user is logged in. For example, say I'm user "Dream". When I log in, I should only see the files that are related to me, such as my downloads, images, and so on.
How could I implement this?
If you have data in database, users has probably its own ID. Personalized content, as images for example, then has to have user ID mark (it creates logic connection). After user is logged, save its ID into session. After he show page with images, pick up user ID form session, select images with user ID mark from database and display them.
If your data are not in database, principle will be the same.

Categories