Welcome Guest, Not a member yet? Register   Sign In
Sharing SESSION Between Multiple Subdomains
#1

I'm using session like bellow in my CI app on a domain (i.e. domain.com)-

PHP Code:
$set['x'] = $id;
$set['y'] = $name;
$set['z'] = $lavel;
$this->session->set_userdata($set); 

Now I want to use these session variables on a subdomain (i.e. sub.domain.com). How to do that..? Is there any option in CI to do that?

Thank you in advance.
"Who thinks in code"
Perfectly describes who I am
mbparvez.me
Reply
#2

(06-21-2015, 04:04 PM)webdevron Wrote: I'm using session like bellow in my CI app on a domain (i.e. domain.com)-


PHP Code:
$set['x'] = $id;
$set['y'] = $name;
$set['z'] = $lavel;
$this->session->set_userdata($set); 

Now I want to use these session variables on a subdomain (i.e. sub.domain.com). How to do that..? Is there any option in CI to do that?

Thank you in advance.

Hi webdevron,

I think you can do that in config.php

Look for these entries.
$config['encryption_key'] = 'encryption';
$config['sess_cookie_name'] = 'sess_cookie_name';

and make it the same to your codeigniter config.php in each of your subdomain.

That will work.

Thanks.
Reply
#3

(06-21-2015, 06:11 PM)jmsmontecillo Wrote:
(06-21-2015, 04:04 PM)webdevron Wrote: I'm using session like bellow in my CI app on a domain (i.e. domain.com)-



PHP Code:
$set['x'] = $id;
$set['y'] = $name;
$set['z'] = $lavel;
$this->session->set_userdata($set); 

Now I want to use these session variables on a subdomain (i.e. sub.domain.com). How to do that..? Is there any option in CI to do that?

Thank you in advance.

Hi webdevron,

I think you can do that in config.php

Look for these entries.
$config['encryption_key'] = 'encryption';
$config['sess_cookie_name'] = 'sess_cookie_name';

and make it the same to your codeigniter config.php in each of your subdomain.

That will work.

Thanks.

That's obvious (even if encryption_key is only relevant for CI2), but the important part is to set cookie_domain to the top-level domain (e.g. domain.com), which allows all its subdomains (sub1.domain.com, sub2.domain.com, etc.) to receive the cookie.
Reply
#4

(06-21-2015, 06:11 PM)jmsmontecillo Wrote:
(06-21-2015, 04:04 PM)webdevron Wrote: I'm using session like bellow in my CI app on a domain (i.e. domain.com)-



PHP Code:
$set['x'] = $id;
$set['y'] = $name;
$set['z'] = $lavel;
$this->session->set_userdata($set); 

Now I want to use these session variables on a subdomain (i.e. sub.domain.com). How to do that..? Is there any option in CI to do that?

Thank you in advance.

Hi webdevron,

I think you can do that in config.php

Look for these entries.
$config['encryption_key'] = 'encryption';
$config['sess_cookie_name'] = 'sess_cookie_name';

and make it the same to your codeigniter config.php in each of your subdomain.

That will work.

Thanks.

I'm using same config file for my domain and sub domain.. So what to do in this case?
"Who thinks in code"
Perfectly describes who I am
mbparvez.me
Reply




Theme © iAndrew 2016 - Forum software by © MyBB