What is the most secure way to implement "Remember Me" functionality in PHP?

Asked by Last Modified  

1 Answer

Learn PHP

Follow 1
Answer

Please enter your answer

Trainer

Use PHP Cookie <?php session_start(); if(!empty($_POST)) { $conn = mysqli_connect("localhost", "root", "", "blog_samples"); $sql = "Select * from members where member_name = '" . $_POST . "' and member_password = '" . md5($_POST) . "'"; $result = mysqli_query($conn,$sql); $user = mysqli_fetch_array($result); if($user)...
read more
Use PHP Cookie <?php session_start(); if(!empty($_POST["login"])) { $conn = mysqli_connect("localhost", "root", "", "blog_samples"); $sql = "Select * from members where member_name = '" . $_POST["member_name"] . "' and member_password = '" . md5($_POST["member_password"]) . "'"; $result = mysqli_query($conn,$sql); $user = mysqli_fetch_array($result); if($user) { $_SESSION["member_id"] = $user["member_id"]; if(!empty($_POST["remember"])) { setcookie ("member_login",$_POST["member_name"],time()+ (10 * 365 * 24 * 60 * 60)); setcookie ("member_password",$_POST["member_password"],time()+ (10 * 365 * 24 * 60 * 60)); } else { if(isset($_COOKIE["member_login"])) { setcookie ("member_login",""); } if(isset($_COOKIE["member_password"])) { setcookie ("member_password",""); } } } else { $message = "Invalid Login"; } } ?> read less
Comments

Related Questions

Where can I get Python online training?
You can get many institutes in google which are providing online training.
Taranum
Looking for Yii Framework experts who are willing to train.
A constructor is a special method of a class in object-oriented programming that initializes an object of that type. A constructor will have same name as the class, and can be used to set the values...
Pritam
Between Java and Python, which one is better to learn first and why?
Both the development programs come with their strong suits. While Java allows you to enjoy the cross-platform support, Python helps you execute on at least ten different operating systems. It would help...
Priyanka
0 0
5
What are the ideas for final year projects based on PHP?
Social Networking System, College Management System, Inventory Management System, eCommerce portal etc.
Nishit
0 0
5

Now ask question in any of the 1000+ Categories, and get Answers from Tutors and Trainers on UrbanPro.com

Ask a Question

Related Lessons

Migration from other languages to Salesforce
Anyone can easily migrate from other language to Salesforce. People must have skills to understand business logic.

What Is PHP?
PHP stands for PHP: Hypertext Preprocessor PHP is a widely-used, open source scripting language PHP scripts are executed on the server PHP is free to download and use PHP files can contain text,...

PHP
It is the base for many of the ecommerce websites. Many of the CMS develpoped in PHP platform.If programming cant done inititally try to think for logics and develop writing algorithms. Any doubts divyaravindiran@gmail.com.

Read Your Gmail Emails Using PHP and IMAP
Hello Friends ,Recently I have worked on drip email campaign project for that I need to read emails using PHP From the gmail inbox. Here is the simple example for Read emails from the gmail: To start...

How to create your website with PHP?
PHP is a server-side programming language used to create web pages that are more interactive than their HTML counterparts. PHP also optimizes the speed of web pages since processing occurs on the server...

Recommended Articles

Almost all of us, inside the pocket, bag or on the table have a mobile phone, out of which 90% of us have a smartphone. The technology is advancing rapidly. When it comes to mobile phones, people today want much more than just making phone calls and playing games on the go. People now want instant access to all their business...

Read full article >

Software Development has been one of the most popular career trends since years. The reason behind this is the fact that software are being used almost everywhere today.  In all of our lives, from the morning’s alarm clock to the coffee maker, car, mobile phone, computer, ATM and in almost everything we use in our daily...

Read full article >

Business Process outsourcing (BPO) services can be considered as a kind of outsourcing which involves subletting of specific functions associated with any business to a third party service provider. BPO is usually administered as a cost-saving procedure for functions which an organization needs but does not rely upon to...

Read full article >

Information technology consultancy or Information technology consulting is a specialized field in which one can set their focus on providing advisory services to business firms on finding ways to use innovations in information technology to further their business and meet the objectives of the business. Not only does...

Read full article >

Looking for PHP Classes?

Learn from the Best Tutors on UrbanPro

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you