Problem with Cakephp environment Auth / Session not working

release

#1

Hello,

i have a problem with my Cakephp Environment. I use Cakephp 3.5 with PHP 7.1.
I checked out the cakephp with composer as mentioned in the book. Then i started developing my Application everything worked fine.
Then i wanted to add User Authentication, and then the problems started :slight_smile:

I tried the default way for user Auth with the standard Auth Component. There it happened, that the login process didnt worked. $this->Auth->identifiy() in the controller login Action was true and in runtime i could access the user object.
But after the redirect the user object was empty again (i run Auth->setUser() too ofc).

Then i tried to fix this issue, i tried several code snippets from Stackoverflow etc, checked Server Environment, changed my dev system from local Ubuntu to my Debian test system. But nothing helped. The Auth User was only available at the time the login happens, after a redirect / reload every Auth Session was empty.

I only need simple user Auth, so I tried to implement this little thing with the normal Session Component (this->request->getSession()->write/read; etc). But the same errors happened, after a redirect / reload every single session variable is null / not there. Then i tried to change my Session storage / Handler from php, to cake, to database) but it doesnt help. I even tried to store my Session vars in the _SESSION variable, but it doesnt help too.

In other non cakephp applications on the server the session thing works just fine.

I run the app with Apache 2.2 without mod_rewrite.

Do you guys have an idea why my Session Environment doesnt work in CakePHP?
I burned several hours in this little problem and this is my last hope too fix this error.

In this case it didnt make sense to post my application code here, cause I tried so much different ways to store the session. At this moment i only have an empty UsersController :smiley:.

I think the whole problem is a specific environment thing with my CakePHP installation. Maybe i can set some configuration vars to fix this.


#2

If I understand you correctly, then you do not save the authorization status when switching to any other page, which may mean that you did not use:

$this->Auth->setUser($admin); // $admin


#3

Hi,
I have the same problem with 3.5.15 Cake version : till 2 days working the same app with no issue on 3 environnements (local windows 10 XAMPP, ubuntu server 16.04 and local MacOs XAMPP). After updating the ubuntu server, logging in creates the session but after redirecting session is null (tested) and so Iโ€™m redirected to login page. Does somenone have any idea ? I have modified the session duration without success, created a new cake instance (3.6.1) and get the same behavior. Something wrong with PHP version ?


#4

Deleting cookies from the browsers can help (see https://github.com/cakephp/cakephp/issues/6053)โ€ฆ


#5

Can u solve this issue?

I have the same problem, in localhost authentication works fine. But, when I publish site, I canโ€™t login any more.

Any solution? folder permission can influenced in this process?