I'm looking for help setting up my website. Here is my delima. I have www.site1.com, www.site2.com, www.site3.com, etc... Each site requires a user to register and/or login. What I am wanting to do is have the user only register and/or login to www.site1.com, and automatically be signed in to all the other sites. The sites are all on the same domain i.e., www.site.com/site1, www.site.com/site2 etc... they each have different sql databasis. I would gladly pay someone to help me right a script or figure this out. If you need any more info, please let me know. Oh, and I though I would add this, I don't know php, so when I say I need help, I really need help. This is basically the last step I need to figure out to get my site running properly.
1 Year Ago
Related Article:Website Development Project
is a Web Development discussion thread by professor123 that has 1 reply, was last updated 9 months ago and has been tagged with the keywords: plan, implement, project.
I'd use PHP session, and set a $_SESSION variable which would then get checked for at the beginning of each page they visit. This will work fine, as long as you're not needing to remember the username next time they visit (i.e. close their browser).
If you do want to remember the login, you'll need to set a cookie, which is a little more complicated. You can read the basics on setting a session here:
In most cases, once the user's logged in, you really only need one $_SESSION variable across your whole site (username). That would look like this in php, and would go before the opening HTML tag on pages where you need the user to be logged in.
On a given page, once you've got the session started and the username php variable set (i.e. $username), then you can use it to call up your user's info from your database. Hope this gives you a start, anyway. Rather than trying to cover the whole thing here, I'd post specific code problems you encounter at each step.
I'm not sure a session will work in my instance. Let me explain my complication. On "www.site.com" I have dolphin 7 running; using database ABC. On "www.site.com/site2" I have osclass running; using database DEF. You see? Both dolphin and osclass require registration and/or login. But I would like the users transition to be able to go from dolphin to the osclass page without having to login.
The session_name must be the same on every page in every subdomain or you will generate a new session id. The set_cookie_params is impt to ensure that all subdomains of site.com ('/' is the following path to include).
I've done this on different domains, i'll see if i can find what i did..
I set it so the login updated the token in both databases, then on the redirect included the token in a GET var, which soon as you jump across to the new site it resets a new token so it cant get hijacked.
so login site1 -> token="12345"
go to site2?token=12345 -> logged in token changed to 15343
back to site1?token=15343 -> logged in token changed to 84512
setcookie("token", $token, $expire, "/");
the final var "/" is the path on your domain the cookie will be visible so set it to "/" and it will appear in any subdirectory on your domain, then you just need to write in the token to all login databases.
which should be an UPDATE mysql query eg. UPDATE users set token = '$token'
make it 3 queries updating all 3 sites databases