1667281860
Facebook login working with CodeIgniter Ion Auth
config/facebook_ion_auth.php
to application/config/facebook_ion_auth.php
.libraries/Facebook_ion_auth.php
to application/libraries/Facebook_ion_auth.php
.application/config/facebook_ion_auth.php
forapp_id
- Your app idapp_scret
- Your app secret keyscope
- custom permissions check - http://developers.facebook.com/docs/reference/login/#permissionsfields
- fields to retrieve from Facebook; if set to ''
, default is id,first_name,last_name
; See https://developers.facebook.com/docs/graph-api/reference/userredirect_uri
- url to redirect back from facebook. If set to ''
, site_url('')
will be usedAssuming that you have installed CodeIgniter Ion Auth, add this in application/config/autoload.php
.
$autoload['libraries'] = array('ion_auth', 'Facebook_ion_auth');
Create application/core/MY_AuthController.php
and put this code into the file
<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* AuthController
*/
class MY_AuthController extends CI_Controller
{
public function __construct()
{
parent::__construct();
$this->load->config('ion_auth', true);
if (uri_string() != 'auth/login') {
$this->_is_login();
}
}
private function _is_login()
{
if (!$this->ion_auth->logged_in()) {
redirect('auth/login');
}
}
}
To auto-load all files in application/core/
, add this code in application/config/config.php
.
/**
| -------------------------------------------------------------------
| Native Auto-load
| -------------------------------------------------------------------
|
| Nothing to do with config/autoload.php, this allows PHP autoload to work
| for base controllers and some third-party libraries.
|
*/
function __autoload($class)
{
if(strpos($class, 'CI_') !== 0) {
require(APPPATH . 'core/'. $class . '.php');
}
}
Extends the default controller application/controllers/Welcome.php
to MY_AuthController.php
for authentication check.
class Welcome extends MY_AuthController {
// ....
}
Create a new controller file application/controllers/Facebook_login.php
with the following code:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Facebook_login extends CI_Controller
{
/**
* Index Page for this controller.
* You will be redirected to the facebook login page
*/
function index()
{
$this->facebook_ion_auth->login();
}
/**
* Controller that is redirected back from facebook after login
*/
public function action()
{
$code = $this->input->get('code');
if ($code) {
$this->facebook_ion_auth->login();
redirect('/');
} else {
redirect('auth/login');
}
}
}
In application/views/auth/login.php
, add "Login with Facebook" button using the Facebook_login controller created above.
<a href="<?php echo site_url('facebook_login'); ?>">Login with Facebook</a>
Update application/config/facebook_ion_auth.php
for redirect_uri
.
$config['redirect_uri'] = site_url('facebook_login/action'); // url to redirect back from facebook.
Then, when you access your application in the browser, you will see the login form with facebook login button.
Author: dgeorgiev
Source Code: https://github.com/dgeorgiev/facebook-ion-auth
1609902140
Angular 9/10/11 social login with facebook using angularx-social-login library example. In this tutorial, i would love to show you how to integrate facebook social login in angular 11 app.
And you will learn how to add facebook social login button with angular reactive login form.
https://www.tutsmake.com/angular-11-facebook-login-tutorial-example/
#angular 11 facebook login #angular 11 social-login example #login with facebook button angular 8/9/10/11 #angular 10/11 login with facebook #angular 10 social facebook login #angular social login facebook
1667281860
Facebook login working with CodeIgniter Ion Auth
config/facebook_ion_auth.php
to application/config/facebook_ion_auth.php
.libraries/Facebook_ion_auth.php
to application/libraries/Facebook_ion_auth.php
.application/config/facebook_ion_auth.php
forapp_id
- Your app idapp_scret
- Your app secret keyscope
- custom permissions check - http://developers.facebook.com/docs/reference/login/#permissionsfields
- fields to retrieve from Facebook; if set to ''
, default is id,first_name,last_name
; See https://developers.facebook.com/docs/graph-api/reference/userredirect_uri
- url to redirect back from facebook. If set to ''
, site_url('')
will be usedAssuming that you have installed CodeIgniter Ion Auth, add this in application/config/autoload.php
.
$autoload['libraries'] = array('ion_auth', 'Facebook_ion_auth');
Create application/core/MY_AuthController.php
and put this code into the file
<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* AuthController
*/
class MY_AuthController extends CI_Controller
{
public function __construct()
{
parent::__construct();
$this->load->config('ion_auth', true);
if (uri_string() != 'auth/login') {
$this->_is_login();
}
}
private function _is_login()
{
if (!$this->ion_auth->logged_in()) {
redirect('auth/login');
}
}
}
To auto-load all files in application/core/
, add this code in application/config/config.php
.
/**
| -------------------------------------------------------------------
| Native Auto-load
| -------------------------------------------------------------------
|
| Nothing to do with config/autoload.php, this allows PHP autoload to work
| for base controllers and some third-party libraries.
|
*/
function __autoload($class)
{
if(strpos($class, 'CI_') !== 0) {
require(APPPATH . 'core/'. $class . '.php');
}
}
Extends the default controller application/controllers/Welcome.php
to MY_AuthController.php
for authentication check.
class Welcome extends MY_AuthController {
// ....
}
Create a new controller file application/controllers/Facebook_login.php
with the following code:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Facebook_login extends CI_Controller
{
/**
* Index Page for this controller.
* You will be redirected to the facebook login page
*/
function index()
{
$this->facebook_ion_auth->login();
}
/**
* Controller that is redirected back from facebook after login
*/
public function action()
{
$code = $this->input->get('code');
if ($code) {
$this->facebook_ion_auth->login();
redirect('/');
} else {
redirect('auth/login');
}
}
}
In application/views/auth/login.php
, add "Login with Facebook" button using the Facebook_login controller created above.
<a href="<?php echo site_url('facebook_login'); ?>">Login with Facebook</a>
Update application/config/facebook_ion_auth.php
for redirect_uri
.
$config['redirect_uri'] = site_url('facebook_login/action'); // url to redirect back from facebook.
Then, when you access your application in the browser, you will see the login form with facebook login button.
Author: dgeorgiev
Source Code: https://github.com/dgeorgiev/facebook-ion-auth
1660835433
In this tutorial we will show you how to create password protected webpage using PHP, HTML and CSS.
In this user have to write correct password to see the webpage content without password user will not be able to see the webpage content.
We make a PHP file and save it with a name password.php
<?php
session_start();
if(isset($_POST['submit_pass']) && $_POST['pass'])
{
$pass=$_POST['pass'];
if($pass=="123")
{
$_SESSION['password']=$pass;
}
else
{
$error="Incorrect Pssword";
}
}
if(isset($_POST['page_logout']))
{
unset($_SESSION['password']);
}
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="password_style.css">
</head>
<body>
<div id="wrapper">
<?php
if($_SESSION['password']=="123")
{
?>
<h1>Create Password Protected Webpage Using PHP, HTML And CSS</h1>
<form method="post" action="" id="logout_form">
<input type="submit" name="page_logout" value="LOGOUT">
</form>
<?php
}
else
{
?>
<form method="post" action="" id="login_form">
<h1>LOGIN TO PROCEED</h1>
<input type="password" name="pass" placeholder="*******">
<input type="submit" name="submit_pass" value="DO SUBMIT">
<p>"Password : 123"</p>
<p><font style="color:red;"><?php echo $error;?></font></p>
</form>
<?php
}
?>
</div>
</body>
</html>
In this step we first check if user logged in or not by checking session variable if the user is not logged in we display login form and if user is logged in we display webpage content with logout button.
We use two isset() condition to do login or logout.In first condition we simply get the password and check if the password is '123' if yes we put the password in session variable and then display the webpage.
In second condition we simply unset the session variable which stores password value. You may also like simple http authentication using PHP .
We make a CSS file and save it with a name password_style.css
body
{
margin:0 auto;
padding:0px;
text-align:center;
width:100%;
font-family: "Myriad Pro","Helvetica Neue",Helvetica,Arial,Sans-Serif;
background-color:#8A4B08;
}
#wrapper
{
margin:0 auto;
padding:0px;
text-align:center;
width:995px;
}
#wrapper h1
{
margin-top:50px;
font-size:45px;
color:white;
}
#wrapper p
{
font-size:16px;
}
#logout_form input[type="submit"]
{
width:250px;
margin-top:10px;
height:40px;
font-size:16px;
background:none;
border:2px solid white;
color:white;
}
#login_form
{
margin-top:200px;
background-color:white;
width:350px;
margin-left:310px;
padding:20px;
box-sizing:border-box;
box-shadow:0px 0px 10px 0px #3B240B;
}
#login_form h1
{
margin:0px;
font-size:25px;
color:#8A4B08;
}
#login_form input[type="password"]
{
width:250px;
margin-top:10px;
height:40px;
padding-left:10px;
font-size:16px;
}
#login_form input[type="submit"]
{
width:250px;
margin-top:10px;
height:40px;
font-size:16px;
background-color:#8A4B08;
border:none;
box-shadow:0px 4px 0px 0px #61380B;
color:white;
border-radius:3px;
}
#login_form p
{
margin:0px;
margin-top:15px;
color:#8A4B08;
font-size:17px;
font-weight:bold;
}
1596183830
Want to create unique, scalable web and app solutions?
At HourlyDeveloper.io, Expert CodeIgniter developer works particularly for you and your project.
You can Hire CodeIgniter Developer with an extensive variety of skill sets together with PHP, MySQL, PHP frameworks such as Laravel, CakePHP, and Zend, CMS, and e-commerce platforms such as WordPress, Drupal, Magento, WooCommerce, Shopify.
Consult with our experts: https://bit.ly/3hUdppScodeIgniter development services
#hire codeigniter developer #codeigniter developer #codeigniter development #codeigniter development company #codeigniter development services #codeigniter
1617355159
One of the fastest, lightest, reliable, and completely capable frameworks for a business web app development is the Codeigniter framework from PHP. CodeIgniter provides out-of-the-box libraries to perform operations like Sending Emails, Uploading Files, Managing Sessions, etc.
Want to build an excellent web application for your business?
Then WebClues Infotech is the right place where you could find highly skilled and expert CodeIgniter developers for hire. Share us your requirement, Conduct desired candidate interviews, and finally choose the one best suitably, it is that easy with WebClues Infotech.
So what are you waiting for? Get going on the path to business growth with WebClues Infotech
For more inquiry click here: https://www.webcluesinfotech.com/contact-us/
Hire CodeIgniter Developer: https://www.webcluesinfotech.com/hire-codeigniter-developer/
Email: sales@webcluesinfotech.com
#hire codeigniter developers #hire codeigniter development expert #hire codeigniter developers #hire codeigniter developers or programmers #hire an offshore codeigniter development team #codeigniter programmer