SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Working on it... Contrid's Avatar
    Join Date
    Apr 2006
    Location
    Online
    Posts
    955
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Joomla - Automatic User Login

    Hey there,

    Do any of you know how to log a user in automatically with Joomla?
    I want to do this upon registration activation and then redirect the user to another page.
    I've tried to use some code in the "activate()" function inside the "components/com_register/registration.php" page. I used the "login()" function inside the "includes/joomla.php" file as reference.

    For some reason my code doesn't want to work at all.
    The cookie is created and it seems like the session is initialized.
    I must be missing something somewhere. I just don't get it. My code is basically exactly the same as the "login()" function.

    Please see if you can help me out.

    Here is my current code :
    PHP Code:
    $query "SELECT id, name, username, password, usertype, block, gid"
    "\n FROM #__users"
    "\n WHERE id = '$result'"
    "\n AND block = 1"
    ;

    $database -> setQuery($query);
    $uUser $database -> loadRow();

    $session = new mosSession($database);

    $session -> guest         0;
    $session -> username     $uUser['username'];
    $session -> userid         intval($uUser['id']);
    $session -> usertype     $uUser['usertype'];
    $session -> gid         intval($uUser['gid']);
    $session -> update();

    //update user visited data
    $currentDate date("Y-m-d\TH:i:s");
    $query "UPDATE #__users"
    "\n SET lastvisitDate = '$currentDate'"
    "\n WHERE id = $session->userid"
    ;

    $database -> setQuery($query);
    $database -> query();

    $lifetime         time() + 365*24*60*60;
    $remCookieName     mosMainFrame::remCookieName_User();
    $remCookieValue mosMainFrame::remCookieValue_User($uUser['username']) . mosMainFrame::remCookieValue_Pass($uUser['password']) . $uUser['id'];
    setcookie$remCookieName$remCookieValue$lifetime'/' );
    mosCache::cleanCache();
    mosRedirect("index.php?option=com_content&task=blogcategory&id=8&Itemid=7"); 
    I put this just below the "echo _REG_ACTIVATE_COMPLETE;" line, which I commented out completely.

    Thank you very, very much.
    And so I got lost in code...completely asphyxiated by it...

    Premium WordPress plugins - Tribulant Software

  2. #2
    Working on it... Contrid's Avatar
    Join Date
    Apr 2006
    Location
    Online
    Posts
    955
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I posted this on the Joomla forums as well, but no-one seems to be able to help me. The code is good. There is just something missing and I don't know what it is. Is anyone familiar with the Joomla session/login verification system? Where exactly is this function located?
    And so I got lost in code...completely asphyxiated by it...

    Premium WordPress plugins - Tribulant Software

  3. #3
    Working on it... Contrid's Avatar
    Join Date
    Apr 2006
    Location
    Online
    Posts
    955
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Any ideas?
    And so I got lost in code...completely asphyxiated by it...

    Premium WordPress plugins - Tribulant Software


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •