Z
Z
zeromind2015-11-08 06:02:22
PHP
zeromind, 2015-11-08 06:02:22

How to implement sessions in php to get a list of sessions and their data?

Hello, I'm very interested in the issue of implementing sessions in php in such a way that in the future it would be possible to get the number of all open user sessions on the server and read their data. I have a project - a streaming server, video is being distributed in HLS format (ts segments are given for 5 seconds), and so .. we need to implement statistics, who is watching what "now (in real time)". As I understand it, all sorts of memcache and redis servers disappear? And do you need a database like mysql ? As a result, I need to render a page that will contain an array of all sessions (each user) and its content ..

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Nazar Mokrinsky, 2015-11-08
@nazarpc

Make your custom sessions.
Get them into the database along with the necessary data.
There it will be possible to search, and sort, and display conveniently. Well, in general, there will be more flexibility, for example, it will be possible to get the number of sessions very quickly and trivially. Well, get rid of some troubles that do not work out of the box in standard sessions (automatic deletion due to obsolescence, cancellation of all user sessions when changing the password, and so on).

V
Vadim Ardanov, 2015-11-08
@ardanow

PHP out of the box stores all sessions in the server's temporary folder, or you can see where exactly they are

<?php 
echo  ini_get( 'session.save_path');
?>

All sessions are stored in the sess_$SESSIONID format.
You can parse this folder by cron, for example, once every 5-10 seconds, and write the data to the table and further along the nakathon.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question