Question

I have two website and use ion auth as login system

the CI structure like this:

CI_BASE
    - system
    - application
        - site1
            - application
                - config
                - controllers
                - view
                - ...
        - site2
            - application
                - config
                - controllers
                - view
                - ...

and now I want to use site1 as main member page

but site2 also can read site1 session and update data to server

site1 domain are: http://1.mysite.com/

site2 domain are: http://2.mysite.com/

how can I connect two website with same auth?

Was it helpful?

Solution

Although not a good practice, the database (if you work with this) and the session configuration, must be the same.

Files: site1/application/config.php, site2/application/config.php

$config['sess_cookie_name'] = 'site_cookie'; // Important! Must be the same name in both sites
$config['sess_expiration'] = 7200;
$config['sess_expire_on_close'] = FALSE;
$config['sess_encrypt_cookie'] = TRUE;
$config['sess_use_database'] = TRUE; // If you work with database
$config['sess_table_name'] = 'sessions'; // Important! Must be the same table
$config['sess_match_ip'] = FALSE;
$config['sess_match_useragent'] = TRUE;
$config['sess_time_to_update'] = 300;

The rest is work with your interface and front-end.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top