Configure _Session to work with applications deployed on multiple servers with different subdomains

I have a website consisting of two applications:

  • Front Panel
  • Backend application

The external interface has a www domain, while the backend has a work subdomain. For example, my frontend application has a domain www.example.com/*, and my backend has a job.example.com/*. My foreground application can be found on one server, while the back end can be on another server . Or they are both stored on the same server.

Now the question is whether the session variables stored in super-global _Session (PHP) can work in different subdomains. If I install _Sesssion["SessionID"]in www.example.com/*, can I get the same _Sesssion ["SessionID"] from job.example.com/*? Do I need to make special adjustments?

0
source share
5 answers

To use the same sessions on multiple domains / servers, you need to take care of two aspects:

  • where the session data is stored so that both domains / servers can access it, and
  • as the session identifier is carried along both domains / servers so that.


, . , , , .


( ) cookie , cookie , cookie . , . www.example.com jobs.example.com, example.com, $domain session_set_cookie_params() .example.com.

+2

, session_save_path, . , , , , , - , ​​ NFS, , .

0

, , , .

0

: http://de.php.net/manual/en/function.session-set-save-handler.php

Use a central database or memcache server.

0
source

Subdomains only affect your cookie, which must be set correctly (as in the domain) in order to save the session ID by going from www. * for tasks. *.

To save the session, you can use the memcache server and use the php_memcache session handler . You do not need to write your own session handler.

0
source

Source: https://habr.com/ru/post/1711067/


All Articles