2008-01-04

How to share PHP session between domain and it's subdomains?

Today I met following task: to share one session between two sites - one site is subdomain of another. Solutions appeared quite simple just need to call session_set_cookie_params ON BOTH sites before call session_start. There is a quick example:

<? session_set_cookie_params ( time()+60*60,'/', '.myhost.com'); session_start(); ?> <html> <head></head> <body> <?php if (!isset($_SESSION['ses_test'])){ $_SESSION['ses_test'] = 1; } print 'Value is: '.($_SESSION['ses_test']++); ?> </body> </html>
 

комментарии:

 
XRumerTest | 2019-11-13
Hello. And Bye.
XRumerTest | 2019-11-14
Hello. And Bye.
XRumerTest | 2019-11-19
Hello. And Bye.
XRumerTest | 2019-11-19
Hello. And Bye.
XRumerTest | 2019-11-19
Hello. And Bye.
XRumerTest | 2019-11-19
Hello. And Bye.
XRumerTest | 2019-11-19
Hello. And Bye.
XRumerTest | 2019-11-19
Hello. And Bye.
XRumerTest | 2019-11-28
Hello. And Bye.
RSS комментариев

Для того чтобы каждый раз не представляться можно войти как зарегистрированный пользователь.

Имя*

разрешены только теги br, font, span, p, strong, u, p, blockquote, a, div, img - остальные будут безжалостно удаляться