Welcome Guest, Not a member yet? Register   Sign In
session id has overwrite when i refresh sub-domain site
#1

[eluser]guzzilar[/eluser]
Hi ci forum
sorry my english language is not good...

-----
My site has 2 application in main-domain & sub-domain

application in sub-domain use CI version 1.7.2
and application in main-domain user CI version 2.1.0

and session is overwrite when i refresh in sub-domain and main-domain

I tested via

in sub.site.com & www.site.com
Code:
function test_sess()
{  
   echo $this->session->userdata('session_id');
}



in my config.php of sub.site.com
Code:
$config['encryption_key'] = 'my_';

$config['sess_cookie_name']  = 'ci_session';
$config['sess_expiration']  = 86400;
$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'] = 86400;

$config['cookie_prefix'] = "";
$config['cookie_domain'] = ".site.com";
$config['cookie_path']  = "/";

and config.php in site.com
Code:
$config['encryption_key'] = 'my_';

$config['sess_cookie_name']  = 'ci_session';
$config['sess_expiration']  = 86400;
$config['sess_expire_on_close'] = TRUE;
$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'] = 86400;

$config['cookie_prefix'] = "";
$config['cookie_domain'] = ".chip.in.th";
$config['cookie_path']  = "/";
$config['cookie_secure'] = FALSE;

Sorry but help me please , I want to fix session_id in 2 site (sub.site.com ,www.site.com) for check login session in database

Thank.
#2

[eluser]InsiteFX[/eluser]
If the database session is store in the same table for both domains then thats your problem.

Each domain should have it's sess_cookie_name and sess_table_name different and each should have its own session table with a different name if running on the same database.


#3

[eluser]guzzilar[/eluser]
[quote author="InsiteFX" date="1342089504"]If the database session is store in the same table for both domains then thats your problem.

Each domain should have it's sess_cookie_name and sess_table_name different and each should have its own session table with a different name if running on the same database.
[/quote]
Thank's for your suggestion

but, when i checked session in both domain i don't store it into database , i use $this->session->userdata('session_id'); for check session id (check by refresh page in both domain toggle) and result is

First refresh: www.site.com >> e9687814977f4fe4286afa863337677d
Second refresh: sub.site.com >> 3bbed7255c4bc02880a0965133d60108
Third refresh: www.site.com >> 9a40d5e6923b6cf9921aa3598e8e8940

and if i use different db name for store session id , how i check session login?
-------------------------------

Thank for reply me hahaha Big Grin
#4

[eluser]InsiteFX[/eluser]
Everytime you refresh a web page the session will regenerate a new session_id

Use a different session userdata field.

So as you can see checking the session_id is useless in this case.
#5

[eluser]guzzilar[/eluser]
[quote author="InsiteFX" date="1342098857"]Everytime you refresh a web page the session will regenerate a new session_id

Use a different session userdata field.

So as you can see checking the session_id is useless in this case.
[/quote]

Sorry i don't understand.

how can i check login session in this case. I tried use other session to check it in site.com (main-domain)
exam :
Code:
$this->session->set_userdata('member' ,'yes');

but in sub.site.com (sub-domain) session 'member' is not appear

and when i use php function
Code:
print_r($this->session->userdata);

i get userdata session array
Array ( [session_id] => a0bb64e596c072d9e271e80977059168 [ip_address] => xxx.xxx.xx.xx [user_agent] => Mozilla/5.0 (Windows NT 6.1) AppleWebKit/536.11 (K [last_activity] => 1342099551 )

What userdata session can i should.

Thank again for your reply Big Grin

// I noob for session & cookie LOL
#6

[eluser]InsiteFX[/eluser]
Set a cookie and pass the login through a cookie you should be able to read the cookie.

Either that or store it in the database and read it back.
#7

[eluser]guzzilar[/eluser]
Alright! ,It's ok.

i use cookie "isLogin" for check .
i try coding in site.com
Code:
function test_sess()
{
     set_cookie('isLogin','yes','86500');

     if(get_cookie('isLogin'))
     {
          echo get_cookie('isLogin');
     }
     else
     {
          echo 'no';
     }
}

and in sub.site.com is
Code:
function test_sess()
{
     if(get_cookie('isLogin'))
     {
          echo get_cookie('isLogin');
     }
     else
     {
          echo 'no';
     }
}

and ok it's echo "yes" in both domain hahaha (I think it's ok)

Thank's very much and sorry for my english language skill hahaha




Theme © iAndrew 2016 - Forum software by © MyBB