简体   繁体   中英

Share Sessions with Main Domain to Subdomain Codeigniter

Hello everyone I want to share the sessions from my main domain with is https://www.waraywarayako.ph/ and my subdmain is https://forum.waraywarayako.ph/ once the user is already login its either in my main domain or subdomain they dont need to relogin again from my forum or main script.

Here is my Config codes in waraywarayako.ph:

$config['sess_cookie_name']     = 'ci_session';
$config['sess_expiration']      = 7200;
$config['sess_expire_on_close'] = FALSE;
$config['sess_encrypt_cookie']  = FALSE;
$config['sess_use_database']    = FALSE;
$config['sess_table_name']      = 'ci_sessions';
$config['sess_match_ip']        = FALSE;
$config['sess_match_useragent'] = TRUE;
$config['sess_time_to_update']  = 300;

$config['cookie_prefix'] = "etc_anything_";
$config['cookie_domain'] = ".waraywarayako.ph";
$config['cookie_path'] = "/";
$config['cookie_secure'] = FALSE;

Here is my Config codes in forum.waraywarayako.ph:

$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'sessions';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = FCPATH . 'application/sessions/';
$config['sess_match_ip'] = TRUE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;
//NOTE THIS SESSION IS FOR MY ADD VIEW FUNCTION
$config['cookie_prefix']    = '';
$config['cookie_domain']    = '';
$config['cookie_path']      = '/';
$config['cookie_secure']    = FALSE;
$config['cookie_httponly']  = FALSE;

I hope anyone can help me with this.. thank you

If both use CI, I would try to put the sessions of the two environments in the same place, a folder on the server that the two can share. (Just a guess)

Something like:

$config['sess_save_path'] = '/home/www/yourpath/sessions/';

in both configs,

$config['sess_save_path'] = FCPATH . 'application/sessions/'; (should be same)
$config['sess_match_ip'] = TRUE;

and

$config['cookie_prefix'] = "etc_anything_";
$config['cookie_domain'] = ".waraywarayako.ph";

Hello every one I just wanted to share it to you the sharing sessions is now workin.. Happy new year everyone..

$config['sess_cookie_name'] = 'sessions';
 $config['sess_expiration'] = 7200;
 $config['sess_expire_on_close'] = FALSE;
 $config['sess_encrypt_cookie'] = TRUE;
 $config['sess_use_database'] = TRUE;
 $config['sess_table_name'] = 'sessions';
 $config['sess_match_ip'] = TRUE;
 $config['sess_match_useragent'] = FALSE;
 $config['sess_time_to_update'] = 300; 


$config['cookie_prefix'] = 'etc_anything_';
$config['cookie_domain'] = '.waraywarayako.ph';
$config['cookie_path'] = "/";
$config['cookie_secure'] = TRUE;
$config['cookie_httponly']  = FALSE;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM