Hi
Is there anyway we can share a login session between two apps one of which is developed in php and the other one in Ruby or Perl or Python?
Thanks
Sharing Sessions b/w 2 different apps?
Page 1 of 17 Replies - 441 Views - Last Post: 31 January 2012 - 03:33 PM
Topic Sponsor:
Replies To: Sharing Sessions b/w 2 different apps?
#2
Re: Sharing Sessions b/w 2 different apps?
Posted 31 January 2012 - 11:17 AM
not that I’m aware of, since every language usually has its own session implementation.
it might work if you have e.g. a database for storing session data, though that requires that both apps use the same serializer (which I doubt).
it might work if you have e.g. a database for storing session data, though that requires that both apps use the same serializer (which I doubt).
#3
Re: Sharing Sessions b/w 2 different apps?
Posted 31 January 2012 - 12:00 PM
Dormilich, on 31 January 2012 - 01:17 PM, said:
it might work if you have e.g. a database for storing session data, though that requires that both apps use the same serializer (which I doubt).
That isn't a problem. You can simply write your own session handlers and have them convert the serialized data to and from whatever format you use when storing the data. As long as the session handlers for both languages know know the persistence format and are able to convert it to whatever format the runtime expects, there should be no problems. Granted, it's a lot of extra work, as you have to write all your own session management code (in both languages), but it's totally manageable.
For examples, check out this article, which describes sharing session data between PHP and Python.
#4
Re: Sharing Sessions b/w 2 different apps?
Posted 31 January 2012 - 12:38 PM
AdaHacker, on 31 January 2012 - 08:00 PM, said:
As long as the session handlers for both languages know know the persistence format and are able to convert it to whatever format the runtime expects, there should be no problems.
I didn’t experiment with setting up my own serializer in PHP yet, so I can’t tell how easy that is.
#5
Re: Sharing Sessions b/w 2 different apps?
Posted 31 January 2012 - 02:06 PM
Dormilich, on 31 January 2012 - 02:38 PM, said:
I didn’t experiment with setting up my own serializer in PHP yet, so I can’t tell how easy that is.
Well, I didn't way that it was easy, just that it was manageable.
Granted, trying to change the session data serialization on the PHP end would be a big pain in the neck. That's probably why the guys in the linked article changed it on the Python side - it's most likely going to be much easier in Python or Ruby than in PHP. To do it in PHP, you would need to parse the serialized session data in the session read and write handlers and convert it to the other format as it goes in and out of storage. The problem is that the session data serialization format is weird - it's similar to a string from serialize(), but not close enough to use serialize() directly and not distinct enough to reliably parse with a simple regex. I don't imagine it would be horribly difficult to write a parser for that format, but it's a non-trivial task.
#6
Re: Sharing Sessions b/w 2 different apps?
Posted 31 January 2012 - 02:18 PM
Why do you want to do this? There's probably a better way for the two application to communicate.
#7
Re: Sharing Sessions b/w 2 different apps?
Posted 31 January 2012 - 03:20 PM
AdaHacker, on 31 January 2012 - 10:06 PM, said:
Granted, trying to change the session data serialization on the PHP end would be a big pain in the neck. […] To do it in PHP, you would need to parse the serialized session data in the session read and write handlers and convert it to the other format as it goes in and out of storage.
I dimly remember that you can set the serialize handler in php.ini. you could simply change it from the default to WDDX (which has a terrible space-efficiency (due to being XML), but is extremely portable (due to being XML))
AdaHacker, on 31 January 2012 - 10:06 PM, said:
The problem is that the session data serialization format is weird - it's similar to a string from serialize(), but not close enough to use serialize() directly and not distinct enough to reliably parse with a simple regex.
I never directly looked at the saved data itself because I assumed PHP would call its standard serialize handler.
#8
Re: Sharing Sessions b/w 2 different apps?
Posted 31 January 2012 - 03:33 PM
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote




|