-
SSL authentication login Script in CakePHP2.3
over 9 years ago
-
over 9 years ago
HI tvellaisa,
Sorry , I cant provide you the number, if you still have any issue related to same query, post it here or any other issue please post new query.
I will surely try to help you. Thanks
-
-
over 9 years ago
hi deepak
Thanks for ur help
can you support through phone
give ur phone no
-
-
over 9 years ago
Please use this code for Login:-
public function login() { if ($this->Session->read('Auth.User')) { $this->Session->setFlash('You are logged in!'); return $this->redirect('/'); } if ($this->request->is('post')) { if ($this->Auth->login()) { return $this->redirect($this->Auth->redirect()); } $this->Session->setFlash(__('Your username or password was incorrect.')); } }
Please check and let me know if it works
Thanks -
-
over 9 years ago
Hi tvellaisa
You will have to set the session.cookie_secure is false
Please use this codeConfigure::write('Session', array( 'defaults' => 'php', 'ini' => array( 'session.cookie_secure' => false ) ));
I hope you are using Session and storing message in Session while submitting the form with the piece of code:-
$this->Session->write('variable', 'value');
After Submitting wherever you need to display put the code
echo $this->Session->flash();
Please check and let me know, if it works
Thanks -
-
over 9 years ago
hi deepak
i check it but not show session message but normal session is working like($_SESSION[])
Thanks
-
-
over 9 years ago
hi abhisek
first thanks for the script
but session message doesn't show and cann't capture any error reload login screen
plz help me
-
-
over 9 years ago
hi deepak first thanks for the script but doesn't work it and show error.
my requirements is after submit login screen never show flash message and can't capture any error plz help me
-
-
over 9 years ago
Hi tvellaisa
Please find the path in your cakephp project folder
app/webroot/.htaccess and /app/.htaccess and delete these files
Now Open .htaccess file inside your project folder e.g(project_folder/.htaccess) and modify the code in it
RewriteEngine on RewriteCond %{SERVER_PORT} !^443$ RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
Disable URL-Rewriting
write the code
Configure::write('App.baseUrl', env('SCRIPT_NAME'));
Please check and let me know if it works
Thanks -
-
over 9 years ago
Hello tvellaisa,
You can do the same using by adding Security component in your controller. Eg.
class WidgetController extends AppController { public $components = array('Security'); public function beforeFilter() { if (isset($this->params['admin'])) { $this->Security->blackHoleCallback = 'forceSSL'; $this->Security->requireSecure(); } } public function forceSSL() { return $this->redirect('https://' . env('SERVER_NAME') . $this->here); } }
Please see cakephp document regarding this. http://book.cakephp.org/2.0/en/core-libraries/components/security-component.html
I hope using above example will fix your issue.
-
9 Answer(s)