PDA

View Full Version : automatic login during registration


jerniganj377713
04-22-2009, 07:29 PM
By default the registration page redirects to the login page after the user completes registration. I would like to have the registration page log the user in to the site when they complete the registration form and redirect them to a secure page within the site.

(when the return they can use the login page)

Does anyone know if there is a way to do this? thanks

Ray Borduin
04-23-2009, 07:47 AM
If you have DataAssist then there is an option to store the newly inserted ID as a session variable. If it matches the login session variable you are using, it is as simple as updating the session variable name in the insert to match the login.

If you are storing more than one session variable at login, and you own ecart or Cookies toolkit, then you will have a set session value server behavior and you can set the session variables that way.

You could probably remove the redirect page from your insert and apply the server behavior to login on the register page as well.

At the end of the day, Login really means setting session variables to match user information, usually at least the ID and sometimes more. Then rules are created to check those values and respond with conditional content or redirects.

At the end of the day all you need to do is set the same session variables that your login sets and they will be logged in. There are quite a few ways that could be done.

neo314
05-15-2009, 11:18 PM
If you want to use the WA redirect features of the login transaction, you can:


Create a login page
Add the security assist include file and session start to the registration page: <?php
if (!isset($_SESSION)) {
session_start();
}
?>
<?php require_once( "WA_SecurityAssist/Helper_PHP.php" ); ?>
Make sure the registration insert transaction DOES NOT REDIRECT.
Add the login transaction code AFTER the registration insert code.
Change the login trigger to the same as the registration trigger: if (((isset($_POST["MM_insert"]))?$_POST["MM_insert"]:"") == "WAATKRegistrationForm") { . . .
Last, make sure the values posted in the registration form are the same as in the login form. For example, don't call it login on the login page and username on the registration form. If that is the case, just modify the login transaction to change "login" to "username" so it matches the registration form.