Cakephp: Login function doesn't work on client server - cakephp

The login function can work on local server and uni server, but it doesn't work on the client's server.
checked the salt, the same as local core.php
checked the password, char(40),
set debug to 2,
deleting the cache files from the app/tmp/cache folder and subfolders,
but nothing happened, I still can not login the system.
I am not sure where I should be looking next, I am very confused.
client server
PHP version:5.3.17
CakePHP: 2.2.3
Many Thanks.

The solution:
Remove all the white space after the end of } tag in controllers and models.
Now, it works.
The reason(found in Google Search):
' the issue is a PHP issue with whitespace being output after some headers are sent, and typically occurs when a redirect is requested further down in the code from the whitespace. This issue has nothing to do specifically with CakePHP as implied in the post title.'
Thanks for help...

I got the SAME problem. removed all the white space after the end tag in PHP in ALL .php and .CTP files. over 1000 of them.
I believe it is something to do with folder permissions because in localhost it works FINE and Dandy and in my case I know the server has a lot of permission issues.

Related

Cannot log in to Drupal site

I have a VM that I set up to do development on two sites hosted on Acquia with the same codebase. I'm using version Drupal 7.26. I have it where I can access both sites from the host computer, but when I try to log in using /user/login on either site, I get nothing. The POST returns a 404 containing the log in page again.
I've tried settings $cookie_domain = '.my-site.dev' as well as $cookie = 'www.mysite.dev'. Neither has any effect. I also tried adding a bunch of random charactersto the file to make sure I was editing the correct file; with the random characters, pages didn't load at all. (See https://www.drupal.org/node/611920#comment-3110010.)
I also tried doing repair table sessions. I forgot which site I saw that recommendation from. I also tried delete from sessions just for kicks. Neither worked.
Any ideas? Thanks!
edit: Per https://www.drupal.org/node/261411#comment-3182566, I tried to go to www.mysite.dev/?q=user/login. This did not give me a 404, but I had tried (unsuccessfully, it seems) to reset my password through the database. I'm at least getting an error about a bad username/password combination rather than nothing at all. Still, I would think /user/login should have worked, too.
edit 2: The production site uses CAS, but logging in through /user/login still works.

Bad Request, Your browser sent a request that this server could not understand

There are two application servers and a switch. When i access application by using application server ip it works fine. However if i use switch ip in my url Bad request error throws up only for firefox and chrome for a few links only.
Here is a detailed explanation & solution for this problem from ibm.
Problem(Abstract)
Request to HTTP Server fails with Response code 400.
Symptom
Response from the browser could be shown like this:
Bad Request
Your browser sent a request that this server could not understand.
Size of a request header field exceeds server limit.
HTTP Server Error.log shows the following message:
"request failed: error reading the headers"
Cause
This is normally caused by having a very large Cookie, so a request header field exceeded the limit set for Web Server.
Diagnosing the problem
To assist with diagnose of the problem you can add the following to the LogFormat directive in the httpd.conf:
error-note: %{error-notes}n
Resolving the problem
For server side:
Increase the value for the directive LimitRequestFieldSize in the httpd.conf:
LimitRequestFieldSize 12288 or 16384
For How to set the LimitRequestFieldSize, check Increase the value of LimitRequestFieldSize in Apache
For client side:
Clear the cache of your web browser should be fine.
If you use Apache httpd web server in version above 2.2.15-60, then it could be also because of underscore _ in hostname.
https://ma.ttias.be/apache-httpd-2-2-15-60-underscores-hostnames-now-blocked/
I just deleted my stored cookies, site data, and cache from my browser...
It worked. I'm using firefox...
Make sure you url encode all of the query params in your url.
In my case there was a space ' ' in my url, and I was making an API call using curl, and my api server was giving this error.
Means the following url
http://somedomain.com?key=some value with space
should be
http://somedomain.com/?key=some%20value%20with%20space
THIS IS CAUSED BY TOO MANY COOKIES!
To SOLVE - Chrome: go into 'developer mode' -> ctrl + shift + i
On top you will see console, network and LITTLE BUTTON THAT LOOKS LIKE ARROWS >>> click on that for APPLICATION
On Left, under STORAGE, find COOKIES.
There will be little DOWN ARROW indicating a drop down, click on this.
now you will see the website something like: www.investing.com
RIGHT CLICK IT and select Clear
Reload.
Works!
Alternatively, clear cookies and cache in a traditional way, and it will work too.
In my case is a cookie-related issue, I had many cookies with extremely big values, and that was causing the problem.
You can replicate this issue here on stackoverflow.com, just open the console and type this:
[ ...Array(5) ].forEach((i, idx) => {
document.cookie = `stackoverflow_cookie${idx}=${'a'.repeat(4000)}`;
});
What is that?
I am creating 5 cookies with a string of length or value of 4000 bytes; then reload the page and you will see the same issue.
I tried it on google.com and you'll get the error but they automatically clear the cookies for you, which is a nice fallback to start fresh.
I was testing my application with special characters & was observing the same error. After some research, turns out the % symbol was the cause. I had to modify it to the encoded representation %25. Its all fine now, thanks to the below post
https://superuser.com/questions/759959/why-does-the-percent-sign-in-a-url-cause-an-http-400-bad-request-error
I'm a bit late to the party, but bumped in to this issue whilst working with the openidc auth module.
I ended up noticing that cookies were not being cleared properly, and I had at least 10 mod_auth_openidc_state_... cookies, all of which would be sent by my browser whenever I made a request.
If this sounds familiar to you, double check your cookies!
in my case:
in header
Content-Typespacespace
or
Content-Typetab
with two space or tab
when i remove it then it worked.
in my magento2 website ,show exactly the same error when click a product,
my solution is to go to edit the value of Search Engine Optimization - URL Key of this product,
make sure that there are only alphabet,number and - in URL Key,
such as 100-washed-cotton-duvet-cover-set,
deleting all other special characters ,such as % .
I got Bad Request, Your browser sent a request that this server could not understand
when I tried to download a file to the target machine using curl.
I solved it by instead using scp to copy the file from the source machine to the
target machine.
If you are getting this error on the WordPress website, check the below solution.
Corrupted Browser Cache & Cookies: Delete your Cookies and clear your cache
Restart your server
For GET Request make sure that passing parameters are url encoded.
if you are using php you can use urlencode function
If you have this same problem and none of the other solutions worked, please check again the url.
In my case it was a space in the end, when it was added to the Cronjob, someone also copied a blank space by accident.
check your data types are correct or not.
for ex: if you send the file, you need to consider to send the full object of the file

cakephp auth login problem, only white screen after login

I’ve created a small cakePHP application that uses the auth component to manage an admin section for changes.
The problem I’m having ‘only in the production environment’ is that after I login all I can see is a blank white screen. I should be redirected to a ‘dashboard’ view. This blank screen is also what I get with all other ‘admin’ prefixed views that require a logged in user, thus the auth component.
What is strange about this are two things, (1) this works fine in the local host and (2) this application is a copy of one that works fine in both the local host and production.
What I’ve done to try and resolve this is:
-Checked the previous application copy; nothing different found
-Checked that the passwords were hashed
-Checked that the .htaccess file was uploaded in ASCII format (suggested by the host)
Any help with this is appreciated.
Ideally I’d like to understand how to trouble shoot this type of problem.
Thanks, Paul
Clear out your tmp cache files anytime you move a cakephp project to a new server or folder. They are located in /app/tmp/cache/

Magento Installation stuck at configuration

I am not sure what is going wrong when I am trying to install magento to my local ubuntu machine.
I did all the steps mentionsed in the magento wiki. Everything goes well until I reach the point where I am here which is the magento config page. When I try and continue after entering the necessary details like host, database name and user name and submit it comes back to the same page. I checked for everything like db in my phomyadmin panel and it still gets stuck there. What is the possible reason for that.
Thanks
Have you try with 127.0.0.1 instead of localhost ?
They have some trouble on login in the admin section.
And check the user/password in the config too !
You have to create a database first and then proceed further.
Step 1 - First create a database with name of your choice like magento
Step 2 - Use that database name in the installation form now
Step 3 - Continue
Hope this solves your problem.
I solved this modifing app/code/core/Mage/Install/etc/config.xml (near 71th string) this
<extensions>
<pdo_mysql/>
</extensions>
for this
<extensions>
<pdo_mysql>1</pdo_mysql>
</extensions>
Verify that you meet the following requirements:
http://www.magentocommerce.com/system-requirements
Magento only runs on php 5.2.x, not 5.3. Also make sure the extensions listed on the requirements page are enabled.
Might be different for you, but I can check the php version using
php -v
Edit
Also what c-verde said about using 127.0.0.1 instead of localhost:
This isn't your current problem, but you'll run into it later. You need to be able to accept cookies to log into Magento. Your browser won't accept cookies for local sites.
In /etc/hosts you need to add
127.0.0.1 localhost.com
And when you install magento you need to use either localhost.com or 127.0.0.1 instead of localhost.
I didn't have this problem with linux, but when installing on windows, it took several minutes after the config page to set up magento. Make sure the browser isn't doing anything.
Before running the installation of Magento:
Navigate to the Varien.php file located in magento/app/code/core/Mage/core/Model/Session/Abstract/Varien.php
You must comment out the last 3 lines in the $cookieParams array:
$cookieParams = array(
'lifetime' => $cookie->getLifetime(),
'path' => $cookie->getPath()
//'domain' => $cookie->getConfigDomain(),
//'secure' => $cookie->isSecure(),
//'httponly' => $cookie->getHttponly()
);
Tick the box for
Skip Base URL Validation Before the Next Step
Check this box only if it is not possible to automatically validate the Base URL.
I also added to my C:\windows\system32\drivers\etc\hosts file
127.0.0.1 www.localhost.com
and removed my magento directory and database tables and started from scratch.
Works for me now.
I did this and it worked!
Navigate to the Varien.php file located in magento/app/code/core/Mage/core/Model/Session/Abstract/Varien.php
You must comment out the last 3 lines in the $cookieParams array:
$cookieParams = array(
'lifetime' => $cookie->getLifetime(),
'path' => $cookie->getPath()
//'domain' => $cookie->getConfigDomain(),
//'secure' => $cookie->isSecure(),
//'httponly' => $cookie->getHttponly()
);
and if you got InnoDB error then do this
Go To Line 59 of the file app/code/core/Mage/Install/Model/Installer/Db/Mysql4.php
Use following code instead of current one
public function supportEngine()
{
$variables = $this->_getConnection()
->fetchPairs('SHOW ENGINES');
return (isset($variables['InnoDB']) && $variables['InnoDB'] != 'NO');
}
Make sure you load php5-mysql extenion. Thats how I solved my problem.
I loaded with http://localhost.com (adding 127.0.0.1 localhost.com to /etc/hosts), it gave my error load pdo-mysql php extension. Otherwise with http://localhost, no error just reloading in configuration page)
I had also been through this problem. I had just create the db first named "magento" and put the 127.0.0.1 instead of localhost. I think, instead of 127.0.0.1, 'localhost' should also work if you had configure it. The problem might be because you didn't have the password for the database but you trying to put the password while installing the magento. Hope this helps some of them.
I had the same problem. Turned out that I was missing a php module but no error was displayed. Megento are now providing a simple php script that checks if the required modules are available and displays an appropriate message if you are missing any of them.
You can find it here - http://www.magentocommerce.com/knowledge-base/entry/how-do-i-know-if-my-server-is-compatible-with-magento
You have to submit username and password as 'root' and 'password' as per db setting
My answer might be late for the PM, but probably useful to those who landed in this page via google.
My experience was that the whole configuration page is a blank page, without any form regarding database, user info or anything.
I fixed it by modifying the {Megento Path}/app/etc/config.xml file.
<default_setup>
<connection>
<host>localhost</host>
<username/>
<password/>
<dbname>magento</dbname>
<model>mysql4</model>
<initStatements>SET NAMES utf8</initStatements>
<type>pdo_mysql</type>
<active>0</active>
</connection>
</default_setup>
Change the value of the host item to anything other than localhost.
Then you get those forms and everything and can move on.
I guess you are missing the port name on which your mysql is running. Try using the port after your hostname for eg. localhost:3306 ,was my configuration settings along with database name and password of your mysql.

Problem in maintaining session between two different domains on a website done in CakePHP

Well as I have posted earlier too...I have created a site in two languages. One with URL www.mainDomain.com (English) and other with www.fr.subDomain.com (French).
Both are done in CakePHP,in french I have just changed the views of it to French. But the problem is, when anybody login's in English version and then switches to the French version, the session doesn't recognizes it and ask for login again. It has become to be the biggest bug in the Web application which I have done till far.
For that, as Swanny told me to go through a link and I did it on my application as it was said on the link.Apparently,it worked for login which shared session between two domains(main domain and it's subdomain). But when I checked it thoroughly, I recognized that both the sites are throwing the latest NEWS from Database, both data are different. Just to check if I was wrong I changed the some save variable to database in session array. But now it refused to remember anything (session). Could anyone suggest me what could be problem with this and how can I resolve this...???
Thanks in advance
I'm not sure I completely understand, but I'm gonna try. I think this is about a PHP setting called session.cookie_domain.
Assuming your websites have the following URLs:
http://www.example.org/
http://fr.example.org/
http://de.example.org/
The setting you want is: .example.org.
You can adjust this in php.ini, a .htaccess file or even in PHP itself:
<?php ini_set('session.cookie_domain', '.example.org'); ?>
If your websites run on two completely different domains, e.g.:
http://example1.org/
http://example2.org/
... then there is no way to share the cookie between these two different domains.
#dooltaz That is a great solution. Be issue is that cake seems to be setting the cookie after me. What I did instead is send the user ro a redirect method and then move the cookie setting to the afterFilter
function afterFilter() {
if (!empty($this->params['url']['session_key'])) {
// Setup variables here...
setcookie(Configure::read('Session.cookie'), $this->params['url']['session_key'], time()+360000, '/');
// Cakes cookie method will put your cookie name in [] so it does not work.
}
}
(Also fixed typo in your code..)
If you have two different domains, I would suggest the following:
On "www.mainDomain.com", put a link to the "www.fr.subDomain.com" site and pass the cookie in your view file:
$session_cookie = $_COOKIE[Configure::read('Session.cookie')];
echo $html->link('See French Site', 'http://www.fr.subDomain.com/?session_key='.$session_cookie);
Then on the french site add a bit of code to mimic the cookies in the app_controller.php > beforeFilter().
function beforeFilter() {
if(!empty($this->params['url']['session_key']) {
// Setup variables here...
setcookie(Configure::read('Session.cookie'), $session_cookie, time()+360000, '/', $domain);
// You could use CAKE's setcookie command here.
}
}
Now that the cookies match up, you will have to either use database sessions or the cake file based sessions. Read the instructions in core.php to set those up.
This should allow you to basically share the same session over various sites. I'm actually in the middle of implementing ACL over multiple sites with a single login. It can get to be a bit tricky, but just do it step by step, you'll do fine. Also don't be afraid to jump into the Cake core code to see how it works.

Resources