Quantcast
Channel: CodeIgniter Forums - All Forums
Viewing all articles
Browse latest Browse all 14115

Using existing session data (from subdomain) in CodeIgniter

$
0
0
I have two websites on the same server -
1) subdomain.mydomain.com where users log in. I setup a session cookie with domain as .mydomain.com
2) my second website is at mydomain.com which is a CI powered website and I got a plain php file at mydomain.com/plain.php

In subdomain.mydomain.com/login.php I setup session cookie as

PHP Code:
session_name('mysess');
session_set_cookie_params(0'/''.mydomain.com');
session_start(); 


In http://mydomain.com/Plain.php

PHP Code:
session_name('mysess');
session_set_cookie_params(0'/''.mydomain.com');
session_start();
echo 
'<pre>'print_r($_SESSION); 

In My CodeIgniter website http://subdomain.mydomain.com/application/config.php

PHP Code:
$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'mysess';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = NULL;
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;
$config['cookie_prefix'] = '';
$config['cookie_domain'] = '.mydomain.com'
$config['cookie_path'] = '/';
$config['cookie_secure'] = FALSE;
$config['cookie_httponly'] = FALSE


Once users login at subdomain.mydomain.com I can see the session data at mydomain.com/plain.php without any issues but as soon as I view any page on mydomain.com/mycontroller/mymethod it overwrites the session data and I lose all the session data set after login at subdomain.mydomain.com

I need that data to see that if a user is logged in or not. I don't want users to login twice that's why I setup cookie as above.
What changes do I need to make in CI config to be able to get that data?

Viewing all articles
Browse latest Browse all 14115

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>