Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is it possible to share session data from a asp.net mvc application and a python application?

I would like to be able to share some data between an asp.net mvc application and a python/django application . The type of data I would like to share are authentification or session data.

like image 905
Dave Avatar asked Mar 07 '12 09:03

Dave


2 Answers

This is of course possible as long as you access some shared resources between both frameworks. There are likely several ways of doing it but one of the most obvious would be using some shared backing store ie. database or maybe even memcached which would be faster. I'm not a Django user but as far as I know memcached is supported in it...

There is of course a more complex scenario related to this and that is data compatibility. You will likely have to use some interchangable format that both frameworks understand ie. XML, JSON, BSON or similar. So even when using memcached you will have to do this translation.

like image 183
Robert Koritnik Avatar answered Oct 11 '22 15:10

Robert Koritnik


How I would share session...

Make the Session Cookie sub-domain agnostic

<httpCookies domain=".mydomain.tld" />

Have my two sub-domains that I want to share session between

www.mydomain.tld [ASP.net MVC app]
extra.mydomain.tld [Python app]

Create a simple web service or generic handler in ASP.net that returns the user's session serialized in JSON or XML.

If you use generic handler remember to use the IReadOnlySessionState or IRequiresSessionState interfaces on the class.

Now from extra.mydomain.tld you can call your www.mydomain.tld/[Get/Set]SessionValue handler or service. It will pick up on your ".mydomain.tld" cookie and allow sharing modifying values.

like image 43
Louis Ricci Avatar answered Oct 11 '22 16:10

Louis Ricci