How to exchange session data between Django and PHP in the same domain

I have a Django application that logs users into and out of the standard Django auth system. The application also uses sessions that are stored in the Django database (db storage is also a Django standard).

So far, so good, but:

In the same domain, I have a large collection of php pages running on apache. I want to be able to log in through my Django application and start django all my session variables, and then when I click on the link that brings me to the php section, I want to have access to the session variables created in Django in php.

What is my best option for sharing a session?

(If that matters, PHP does not edit the session using only variables)

+3
source share
2 answers

In PHP, you can implement your own custom session handler . Connect to the database that stores the session data from the Django database, and this data will be transparently presented in PHP as session values.

The advantage of a custom session handler is also that you can make this session in PHP write protected, you just discard any changes.

Next to this, you need to split the session identifier , it is connected to the session name . I don’t know Django well, but I think there is something comparable, so if you make it compatible with cookies or URL parameters, it may even work instantly.

+1

!! ( ). , .

django_php_bridge db.py phpserialise (1.2),

. , if serialize, unicode, djang_php_bridge docs ( SESSION_COOKIE_NAME django), .

- , , django_php_bridge phpserialize, , .

0

All Articles