Note that there are some explanatory texts on larger screens.

plurals
  1. PO$request variable empty after a post
    primarykey
    data
    text
    <p>I'm facing this weird problem on CakePHP, when I try to login into the administration of my website locally (/users/login), I enter my username and password and works just fine but after I uploaded it to a remote server, the same code, sambe database won't allow the user to login, it says the username/password is invalid, but after a few hours trying to figure out what was going on I found that the variable <strong>$request</strong> inside the <strong>authenticate</strong> method from FormAuthenticate.php is basically empty, it's coming like this into the remote server:</p> <pre><code>object(CakeRequest) { params =&gt; array( 'plugin' =&gt; null, 'controller' =&gt; 'users', 'action' =&gt; 'login', 'named' =&gt; array(), 'pass' =&gt; array() ) data =&gt; array() query =&gt; array() url =&gt; 'users/login/' base =&gt; '' webroot =&gt; '/' here =&gt; '/users/login/' } </code></pre> <p>however, the same page, running locally returns:</p> <pre><code>object(CakeRequest) { params =&gt; array( 'plugin' =&gt; null, 'controller' =&gt; 'users', 'action' =&gt; 'login', 'named' =&gt; array(), 'pass' =&gt; array() ) data =&gt; array( 'User' =&gt; array( 'password' =&gt; '*****', 'username' =&gt; 'admin' ) ) query =&gt; array() url =&gt; 'users/login/' base =&gt; '' webroot =&gt; '/' here =&gt; '/users/login/' } </code></pre> <p>I tried to find anything that might be causing this but still no luck, I'm new to CakePHP so I might be missing something, thanks!!</p> <hr> <p>update #1, here's my UserController::login method</p> <pre><code>public function login() { $this-&gt;layout = 'default_admin'; if ($this-&gt;request-&gt;is('post')) { if ($this-&gt;Auth-&gt;login()) { $this-&gt;redirect($this-&gt;Auth-&gt;redirect()); } else { $this-&gt;Session-&gt;setFlash(__('Invalid username or password, try again')); } } } </code></pre> <hr> <p>update #2: I've changed the form method from "post" to "get" using the developers tools from chrome and then on UserController::login() I changed to: ... if ($this->request->is('get')) { ... and then It worked, but I need it to work with "post" method though =\</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload