Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Data Model Questions

Logging in Users / Sessions / Cookies - Allways logs me out


Reply

257 Views

Avatar
FlorianGER

22 November 2013 at 2:14am (Last edited: 22 November 2013 2:22am), Community Member, 1 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