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>
 

comments:

 
mcfncw (Anonymous user) | 2018-04-25
cialis cialis australia online shopping http://canadian-pharmasy.com
etypxj (Anonymous user) | 2018-04-27
womens viagra where can i buy viagra in stores http://canadian-pharmacie.com
commenting RSS

You may not introduse yourself each time you leave a comment if you enter as registered user.

Name*

There are only br, font, span, p, strong, u, p, blockquote, a, div, img - tags allowed here, other tags will be removed

разное (182)
howto (123)
программирование (108)
гад-же-ты (75)
мысли (42)
PHP (41)
JavaScript (39)
вебмастеринг (37)
linux (28)
гондураша (28)
юмор (25)
полезное (21)
движок (17)
Android (16)
софт (15)
деньги (14)
видео (13)
кино (13)
музыка (10)
беспредел (10)
путешествия (10)
интернет (9)
diy (9)
ztools (8)
книги (8)
умный дом (8)
занимательная физика (8)
языки (7)
хостинг (7)
Nokia 5800 (7)
lifehack (6)
css (6)
вебдизайн (6)
apple (5)
arduino (5)
связной (5)
прелоадер (5)
козлы (5)
oDesk (5)
занимательная юриспруденция (4)
svn (4)
кухня (4)
Python (4)
энергия (3)
рестораны (3)
software (3)
synphony (3)
Java (2)
webmastering (2)
фото на документы (2)
Ruby on Rails (2)
спорт (2)
bash (2)
движек (2)
гитара (2)
аниме (2)
дурдом (1)
C++ (1)
годнурас (1)
микросервисы (1)
SEO (1)
programming (1)
технологии (1)
наука (1)
сайты (1)
авторское право (1)
восстановить (1)
Search in blogs:

Valid XHTML 1.0 Strict