Nima habibkhoda
Nima habibkhoda

Reputation: 253

Share codeigniter session from database on two different domain in one server

I have two websites with Codeigniter on one server with two different databases,

for example I have mydom.com and mydom2.com and set my config.php on mydom.com as below :

$config['sess_driver'] = 'database';
$config['sess_cookie_name'] = 'ci_sessions';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = 'mydom.ci_sessions';
$config['sess_match_ip'] = false;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = false;

and the mydom2 config.php :

$config['sess_driver'] = 'database';
$config['sess_cookie_name'] = 'ci_sessions';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = 'mydom.ci_sessions';
$config['sess_match_ip'] = false;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = false;

both of them are same, mydom2 is connected to mydom database in line sess_save_path. Session is working , but they are different , when I login in mydom , session is set , but on mydom2 it is not set. Why?

Upvotes: 2

Views: 957

Answers (1)

Nikunj Chotaliya
Nikunj Chotaliya

Reputation: 802

I think You should try with change cookie name and sessions saved table name. Reference link https://www.codeigniter.com/user_guide/libraries/sessions.html#database-driver

Upvotes: 1

Related Questions