views:

61

answers:

2

I need to keep a persistent connection open across multiple page requests. You cannot put PHP resources into the session.

My solution is to trigger a deamon on the first request and keep the PHP resource there. I then need to get the deamon to talk to my different page requests. I could do this the long way by using a database or file but I was wondering if I could somehow share the session...

Is this possible, and if so... how??

If you have a better solution to maintain persistent connections or if this is a particularly rubbish idea... please let me know.

+1  A: 

You cannot put PHP resources into the session.

Yes you can. Serialize the object or variable and then put it into a session.

http://php.net/manual/en/function.serialize.php

Andrew Sledge
" serialize() handles all types, except the resource-type." http://php.net/manual/en/function.serialize.php
Tom Haigh
It will sucessfully go into the session but similar to __sleep() the connection gets terminated.
Simon
A: 

Shared sessions is a non-starter. Will use a queuing mechanism or MySQL to talk to my deamon.

Simon
Could use Memcache, http://au2.php.net/manual/en/class.memcache.php
grom