开发者

How to share a session with a Erlang application

开发者 https://www.devze.com 2023-01-02 22:37 出处:网络
I need to create a chat in Erlang. Is there a way to share the session between PHP and Erl开发者_如何学运维ang applications ?Yes, it would require several conditions:

I need to create a chat in Erlang.

Is there a way to share the session between PHP and Erl开发者_如何学运维ang applications ?


Yes, it would require several conditions:

  1. Both Erlang & PHP should rely on identifying sessions or HTTP with a cookie name, exchanged over the same domain (or wildcard-domain).
  2. The should both be able to read the format in which the session is stored (json comes to mind, or peb_connect() in php )
  3. You should only store 'simple' structures in the session, which both can understand (arrays, hashmaps,, strings, integers, anonymous objects would be pushing it a bit)
  4. They should use a locking mechanism for read/writes that both can use (otherwise you have the chance new values are overwritten with stale data)

For PHP this means you should write your own handler for a session (see http://nl2.php.net/manual/en/function.session-set-save-handler.php), as far as I gather Erlang can use the same thing (well, the Erlang implementation is up to you).

The Erlang / PHP bridge may be used, but strictly speaking it is not necessary, it could save some work though.

Also of note: http://code.google.com/p/mypeb/wiki/ErlangAsSessionStorageForPHP

0

精彩评论

暂无评论...
验证码 换一张
取 消