Customizing SMF > SMF Coding Discussion
Logging in before accessing smf
mrdogfood97:
Hi! I am trying to use SMF in a website I am creating, and what I want to do is have the actual forum in a seperate folder to all the other pages, because I want an image gallery and a diary as well, and I don't want to use SMF for that. What I have got going on is this: when you first load the page you get a form with a username and password field. After you click login the seperate "login.php" file checks the username/password against the database (I created a seperate table in the smf database to store the simple username and password), and stores the unhashedpassword and username in two session variables, username and password. After that you get redirected to a members page (members.php) where there are links to the gallery and diary etc. there is a link to the forum as well, and this is where i need your help: now when you click the link, it takes you to htdocs/forum/index.php?action=login which is basically the login page to smf. I would like it so you don't have to enter the username and password with the session variables i stored in the login.php I have tried many things like looking through the source code of the smf login.php and ssi.php, but found nothing. Sorry about the long post, thanks in advance. :)
emanuele:
Since you are apparently already using SMF database, have you already considered ssi_login?
--- Code: ---<?php
require_once('/path/to/SMF/SSI.php');
ssi_login('http://www.yoursite.tld/');
--- End code ---
this will output a login form (i.e. a username and a password input fields) that will validate the username and passwrod against SMF database and if the login is successful will redirect the user to http://www.yoursite.tld/ that you can change to whatever you want.
That way you don't need to store any additional information (in a non-particularly-safe way).
mrdogfood97:
Oh I see, sorry about the stupidity ;D Thank you
mrdogfood97:
--- Quote from: emanuele on September 01, 2012, 08:47:36 AM ---Since you are apparently already using SMF database, have you already considered ssi_login?
--- Code: ---<?php
require_once('/path/to/SMF/SSI.php');
ssi_login('http://www.yoursite.tld/');
--- End code ---
this will output a login form (i.e. a username and a password input fields) that will validate the username and passwrod against SMF database and if the login is successful will redirect the user to http://www.yoursite.tld/ that you can change to whatever you want.
That way you don't need to store any additional information (in a non-particularly-safe way).
--- End quote ---
But does this set the session variables in the actual SMF page? smf and the other pages are on the same server, only in a different directory.
emanuele:
It sets up both the session and the cookie., in fact (unless there is bug) it should be completely equivalent to login through the usual SMF login box.
Navigation
[0] Message Index
[#] Next page
Go to full version