Jump to:

3375 Posts in 999 Topics by 712 members

Data Model Questions

SilverStripe Forums » Data Model Questions » Logging in Users / Sessions / Cookies - Allways logs me out

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 180 Views
  • FlorianGER
    Avatar
    Community Member
    1 Post

    Logging in Users / Sessions / Cookies - Allways logs me out Link to this post

    Hey Guys!

    I got a Problem with an own LogIn Module.

    Explanation:

    I have a Controller "MemberHandler_Controller".

    Routing:

    Director:
    rules:
    'base': 'MemberHandler_Controller'

    Then i have a AJAX-Form which will LogIn a Member.

    // Login Form
    $("#loginForm").submit(function(event) {
    var email = $("#inputEmail").val();
    var pw = $("#inputPassword").val();
    var remember = $("#rememberLoginInput:checked").length ? "True" : "False";
    $.ajax({
    url: PreUrl+"base/login",
    data: {email: email, pw: pw, remember: remember},
    dataType: "json",
    type: "POST"
    }).done(function(result) {
    if (result.success) {
    window.location = PreUrl;
    } else {
    $("#loginMessageArea").html(ErrorPreHTML + result.message + ErrorAfterHTML);
    }
    });
    event.preventDefault();
    });

    To avoid some stupid Errors i have shrinked the Login Method to that:

    public function Login(SS_HTTPRequest $request) {
    $email = "test@test.com";
    $user = OBUser::get()->find("Email", $email);
    $user->logIn($remember);

    echo json_encode(array("success" => true));
    }

    Now i Press the Login Button at http://localhost/ProjectName/

    It will send an Request to: http://localhost/ProjectName/index.php/base/logout

    Now i get redirected by JavaScript to: http://localhost/ProjectName/index.php

    I can browse the Page now, on every underpage i am logged in like on:
    http://localhost/ProjectName/index.php/about-us/
    or
    http://localhost/ProjectName/index.php/contact-us/

    BUT if i go to a site without the "index.php" like http://localhost/ProjectName/ i am Logged Out...
    if i go back to http://localhost/ProjectName/index.php i am still logged in.

    What is the Problem?

    Very much Thanks in Advance

    180 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.