Storing Socket in $_SESSION variable

It is not possible to store a socket connection in a session variable in order to keep it open. Instead, use the PHP function pfsockopen to open a socket connection and leave it opened between web requests. This function only allow the connection to be persistent when you are not using CGI mode or running the script as a CLI script.

However, the pfsockopen function does not allow you to keep track of the socket on a per user basis. It will simply return you the one that was opened previously.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockquote>
  • You may post PHP code. You should include <?php ?> tags.
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. Beside the tag style "<foo>" it is also possible to use "[foo]". PHP source code can also be enclosed in <?php ... ?> or <% ... %>.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options