G
G
GM2mars2016-01-29 13:51:33
PHP
GM2mars, 2016-01-29 13:51:33

How to set a common domain for creating sessions on subdomains in php?

There are two subdomains main.site.ru and api.site.ru . Main is for the frontend and api is for the backend. They communicate through ajax requests. The service has authorization through sessions. The session is created on api.site.ru and, accordingly, requests from the main.site.ru domain do not have this session.
How to configure sessions in php so that they are created for the site.ru domain and work on subdomains?
upd: it seems to be done through this thing php.net/manual/ru/function.session-set-cookie-para...
I would be grateful if someone writes with an example, since I myself am not strong in server languages.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
W
Walt Disney, 2016-01-29
@GM2mars

ini_set('session.cookie_domain', '.site.ru' );

A
Andrey Burov, 2016-01-29
@BuriK666

no way. You can only on site.ru make a session to the domain .site.ru

A
Andrew, 2016-01-29
@R0dger

Well, communicate with a token .. received .. gave .. checked at the front made a session, etc. ... or put a cookie on .site.ru

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question