# Handle a user forum login

1. <?php
2. # Handle a user forum login
4. if (!defined('PHORUM')) return;
6. require_once("./include/api/base.php");
7. require_once("./include/api/user.php");
9. // Check the username and password.
10. $user_id = phorum_api_user_authenticate(
11. PHORUM_FORUM_SESSION, // for a standard front end forum session
12. "username", // the username to check
13. "password" // the password to check
14. );
15. if (!$user_id) die("Username or password incorrect!\n");
17. // Make the authenticated user the active user for Phorum. This is all
18. // that is needed to tell Phorum that this user is logged in.
19. $set_active = phorum_api_user_set_active_user(
20. PHORUM_FORUM_SESSION, // for a standard front end forum session
21. $user_id, // the user_id that has to be the active user
22. PHORUM_FLAG_SESSION_ST // jumpstart the short term session
23. );
24. if (!$set_active) die("Setting user_id $user_id as the active user failed!\n");
26. // Create a session for the active user, so the user will be remembered
27. // on subsequent requests.
28. phorum_api_user_session_create(
29. PHORUM_FORUM_SESSION, // for a standard front end forum session
30. PHORUM_SESSID_RESET_LOGIN // reset session ids for which that is
31. ); // appropriate at login time
33. ?>

Documentation generated on Wed, 17 Mar 2010 01:45:26 -0500 by phpDocumentor 1.4.1