A session is a simple thing that can be easily overestimated to do what you need. Take a look at this simple example that I wrote a while ago: http://pastebin.com/f3ca0ae8d
Using:
new mySession(); do the same as session_start();$_MYSESSION do the same as $_SESSIONdelete mySession(); do the same as session_write_close(); no need to use if you do not want to free the session until the end of the script.
You can make some changes to use them for your specific purpose, for example, to independently determine the session identifier so that you can share them among different users. Since $ _MYSESSION will be distributed to users, you can also use regular PHP sessions with it to store user information in $ _SESSION.
[change]
http://pastebin.com/f3c31737e
Example: enter channel $ _SESSION ['channelid'] and print all unread lines.
session_start(); new mySession($_SESSION['channelid']); while (count($_MYSESSION['chat']) > 100) unset($_MYSESSION['chat'][key($_MYSESSION['chat'])]); while ($line = $_MYSESSION['chat'][$_SESSION['lastread']++]) echo "$line
";
Example: talk to the channel.
session_start(); new mySession($_SESSION['channelid']); $_MYSESSION['chat'][] = $_SESSION['myname'] . ' says, "' . htmlspecialchars($_POST['message']) . '"';
etc...
Havenard
source share