Hi all,
I know this is a common question as I have seen in so many posts, but I have yet to find a clear answer that got me going and would greatly appreciate a complete code example or link to one.
Just installed SMF 1.1.13 and everything is working great.
Now I need to integrate my existing home page login to silently auto-login the user to the SMF forum, but NOT to redirect them to the forum index.php automatically.
I am using PHP to capture the user login ID and password via HTTP form post and then check it against stored mysql data. A pretty straight forward scenario.
So, assuming I have the PHP variables $member and $password, how do I send these to SMF for silent (bridged) login? The member (user) credentials have already been stuffed into the SMF mysql members table and work fine when I call ssi_login() and log in again, so the credentials are in place correctly. Also, using ssi_login I was able to successfully redirect the user to one of my other site pages and not SMF, yet they were logged in whenever going to SMF, so all is good there.
I want to avoid the need for the second login prompts and I have read a good deal on the integration hooks, which looks to me as the correct answer.
Can someone provide a sample of code (or a link) I could use to pass the login information to SMF?
Thanks in advance!
Jim
have you read
How to use the SMF user system outside of SMF (http://wiki.simplemachines.org/smf/How_to_use_the_SMF_user_system_outside_of_SMF)
SSI Readme (http://wiki.simplemachines.org/smf/Category:SSI)
How do I integrate SMF into my PHP coded website? (http://wiki.simplemachines.org/smf/How_do_I_integrate_SMF_into_my_PHP_coded_website) ?
Thanks for the prompt reply Illori.
I did read those posts. Using the SSI functions to log into the SMF first from my home page and then redirecting the user to another page would work, but would cause me some problems with other criteria I want to check before deciding where to send the user. There are other factors for me to consider and that info is stored only in my site mysql database and not in the SMF databases.
Of course, I could duplicate the additional info in the SMF db(s) as well or do a join on multiple db's, but that would create additional overhead... Something I am looking to avoid due to the nature of the site and the amount of data that will eventually be stored.
In reading some of the other posts on integration, it sounds like many other people have been able to have users log in on one unrelated page and then to pass the login info on to SMF via either hooks or curl. I attempted both methods and still get a "guest" welcome at SMF, so my structure is obviously wrong. SSI does work fine for me, but would require either a duplicate login or the overhead I mentioned above.
If I could find a good example of using one of the other methods, I could solve the problem by handling the login and security as I do now, but also in performing a silent login to SMF, allowing the user to access the forum when ready, already logged in.
Any additional help or direction would be appreciated.
i think most people that use integrated logins have them in the same database, which makes it easier. best i can suggest is posting in the code discussion board and see what others suggest you do.
I'm sure you are correct. Thanks for the help.
What I might try doing is moving my "other" criteria checking PHP code to the SMF php files login section and then use SSI to login as you suggested. In doing so, I can have one login but still perform the other checks against my own db.
That might solve the problem without requiring other methods. If not, I will certainly check with some of the other folks.
Thanks again...
Played around a bit more and discovered something really simple and hopefully useful to other 1.x users... By adding the following code to my site's login function, I am able to capture the posted user ID and password and then populate the correct SMF variables to achieve a silent SMF login, while still directing the user to the desired site page.
include_once('/path/to/SSI.php');
include_once('/path/to/Sources/LogInOut.php');
$username = $_POST['username'];
$password = $_POST['password'];
$_REQUEST['user'] = $username;
$_REQUEST['passwrd'] = $password;
$_SESSION['login_url'] = 'http://www.yourdomain.com/desiredpage';
login2();
As long as you have already added the user to the SMF members database either programatically or manually, this method works fine.
This might help other people looking for a short, simple way to use a slilent login.