how opencart login works

In this  post I am going to discuss regarding the opencart login say HOW OPENCART LOGIN WORKS.Files used in login functionality are

1) /oc2302/catalog/controller/account/login.php


3) /oc2302/catalog/model/account/customer.php

4) /oc2302/system/library/cart/customer.php file

flow of the opencart login functionality is as shown below.

opencart login functionality flow

When  user visit My Account -> login the url is something like http://localhost/oc2302/index.php?route=account/login (here I have installed opencart in oc2302 directory)

The screen looks like as below at this url.

opencart login page

Here route=account/login so controller used is  login.php and its full path is /oc2302/catalog/controller/account/login.php

login controller contains two functions index() and validate().

Let me drill down the index() function

Here I am going to highlight the important line of code only

Line no 6 is

This line loads customer model and its location is   /oc2302/catalog/model/account/customer.php

Line no 9 is

which override login for admin users. this if loop ends at line no line no 44 check for if user is already logged in if it than it will redirect it to account page.Other wise it will goto line no 52

in above code snippet it checks for if method used is POST and also it use validate function.validate function records invalid login attempts if either email or password is wrong. If both email and password is ok than it will remove invalid attempts

in validate function at line no. 201

this line call the model login method and its successful it will returned back to the index() method else it will show error message.

Here the login function is available at

/oc2302/system/library/cart/customer.php file

Here at login() method it will check for if email and password is exist in database or not and also check if user  status is active. If  it exits than It will return true.

Its my first post on opencart. will post more posts in future . if you need any specific post please feel free to contact me.

Good Day,


Leave a Reply

Your email address will not be published. Required fields are marked *