How to save session information when redirecting from one subdomain to another?

I am programming PHP.

I want to redirect ht tps: //abc.example.com/blah1/blah2 in htt ps: // w ww.example.com/blah1/blah2 but I don't want to redirect htt ps: //abc.example.com redirect to ht tps: // ww w.example.com

Is it possible to save session information through redirects?

Thanks.

+3
source share
5 answers

, , session.cookie_domain (, example.com). , session_set_cookie_params session.cookie_domain php.ini( .htaccess php_value). .

+3

cookie , cookie . www.example.com foobar .example.com, cookie example.com, www.example.com, foobar .example.com.

+1

Apache,

RedirectMatch /(.+) https://www.domain.com/$1

PHP

<?php


    if ($_SERVER['REQUEST_URI'] != "/") {
        header("Location: ".$_SERVER['REQUEST_URI']);
        exit;
    }

?>

, Gumbo, cookie .

0

I would say that you can redirect by sending (POST) your sessionid to the new domain and save your session data in mysql using your own session handler.

0
source

Use javascript redirection.

-2
source

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


All Articles