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>
разрешены только теги br, font, span, p, strong, u, p, blockquote, a, div, img - остальные будут безжалостно удаляться
комментарии: