pixeltrace Posted May 8, 2007 Share Posted May 8, 2007 guys, i need help. i have 2 different domains which needs to use the user account, or cookie. let say i login to www.domain.com and then i go to www.domain-2.com. when i go to domain-2.com if i am already logged in to domain.com i will automatically be logged in to domain-2.com and vice -versa. is this possible? if so, what will the code be and how to do it? thanks! Quote Link to comment https://forums.phpfreaks.com/topic/50429-how-to-use-session-on-2-diff-domains/ Share on other sites More sharing options...
suttercain Posted May 8, 2007 Share Posted May 8, 2007 You could create a database, to be shared by both domains and store the sessions in that database. Somthing like: - sessionkey - text - expiration Quote Link to comment https://forums.phpfreaks.com/topic/50429-how-to-use-session-on-2-diff-domains/#findComment-247750 Share on other sites More sharing options...
utexas_pjm Posted May 8, 2007 Share Posted May 8, 2007 Session data is simply data that is saved on the server's disk such that it can persist between HTTP requests. Typically the server will set a cookie on the client (although this can also be accomplished by passing the session hash in the query string) with a hash which uniquely identifies the data saved on the server's disk. If the two domains point to two separate servers then I don't believe this is possible at all. If the domains do point to the same server then it becomes a matter of getting at the session ID. The previous poster's solution should be adequate in the latter example, as cookies cannot be shared across domains. Best, Patrick Quote Link to comment https://forums.phpfreaks.com/topic/50429-how-to-use-session-on-2-diff-domains/#findComment-247835 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.