Is my login function secure ? how to improve it?
I answered you on SO but I'll repeat it here too.

Please read the CakePHP Documentation, preferably from the start because you really are getting a lot wrong here.


There is no need to addslashes() everything, (or anything ever)
CakePHP has it's own AuthComponent, so no need to roll your own
It also has a validation engine, so no need to validate anything here
You're also passing some Request object to the method? I don't even want to ask...


This action should basically be about 6 lines long. TL;DR: Read the CakePHP Authentication docs, and start again.