Welcome Guest, Not a member yet? Register   Sign In
sharing sessions
#1

[eluser]Lupin[/eluser]
Hi,
I have been looking around the net for some solutions & ideas & didn't really find good leads.
I have a web application that consists of 2 sites with different domains. they both sit in the same server with the same CI installation & the domains are alias.

I want to be able to know when a user has logged in to one of the sites even if he is in the second one. meaning that if a user logged in in site A & then went to site B , my system will recognize him & he could continue without the need to login again.

I believe this is a session sharing issue but not sure how exactly to implement it. I have set the session storage to Database & tried to sent the session id from site A to B & use it there but no luck.

Any idea & suggestion would be welcomed.

Cheers,
#2

[eluser]TheFuzzy0ne[/eluser]
As long as the cookies share the same domain, I wouldn't have thought it would be a problem. I can't be 100% certain of that though, but I am sure sub1.mysite.com should be able to access cookies for mysite.com or sub2.mysite.com for example.
#3

[eluser]Lupin[/eluser]
Thanks for the reply, but i meant 2 differnt domains and not sub domains.

www.a_site.com
www.b_site.com
#4

[eluser]TheFuzzy0ne[/eluser]
I might be wrong, but to my knowledge that's impossible. Otherwise any Web site would be able to read cookies for any other Web site.

Hopefully someone else can think of a way around this.
#5

[eluser]pistolPete[/eluser]
There is an example:
http://www.melbournechapter.net/wordpres...e-domains/
#6

[eluser]Lupin[/eluser]
Thanks,
Actually, i have also found that post, but didn't succeed implementing it in CI
#7

[eluser]Lupin[/eluser]
Hi,
A quick update,
I have found the solution for this, however i am using the Native Session class for Codeignitor [http://codeigniter.com/wiki/Native_session/] due to previous issues.

The simple solution was just to get the session from one domain, send it in the URI to the second domain there i have an if statement in the session library, if i found the first site session id i just sigin it in when starting the session -
Code:
session_id($s_id)
;

This solution works, but i believe it will only work when the domains share the same session location & in my case the domains are alias, so they share the code.

I will later build a function for other that might need it, & try to do the same with the original CI session library.

Cheers




Theme © iAndrew 2016 - Forum software by © MyBB