Posts

Showing posts from August, 2024

Create Login using JWT(JSON Web Token) Token in PHP

Image
  <?php require "vendor/autoload.php" ; use Firebase\JWT\ JWT ; use Firebase\JWT\ Key ; $error = "" ; $host = "localhost" ; $username = "root" ; $password = "" ; $database = "test" ; if ( isset ( $_POST [ "login" ])) {     $connect = new PDO ( "mysql:host= $host ; dbname= $database " , $username , $password );     if ( empty ( $_POST [ "student_name" ])) {         $error = "Please Enter Name Details" ;     } else if ( empty ( $_POST [ "age" ])) {         $error = "Please Enter Age Details" ;     } else {         $query = " SELECT * FROM students WHERE student_name = :student_name " ;         $payload = [             "student_name" => $_POST [ "student_name" ]         ];         try {             $statement = $connect -> prepare ( ...

JWT(JSON Web Token) (Sixteen Token) Creation with CURL and Expire Time in CodeIgniter 3

  <?php defined ( "BASEPATH" ) or exit ( "No direct script access allowed" ); use Firebase\JWT\ JWT ; use Firebase\JWT\ Key ; class RequestSixteen extends CI_Controller {     public function __construct ()     {         parent :: __construct ();     }     public function index ()     {         $key = "Sixteen_Key" ;         /*$data = [             //This is used in case of POST request to pass data             "username" =>  "user@3944",             "password" => "3228"         ];*/         //Set the expiration time to 2 hour from the current time         $issuedAt = time ();         $expirationTime = $issuedAt + 7200 ;     //jwt valid for 2 hour from the issued time ...

JWT(JSON Web Token) (Fifteen Token) Creation with CURL and Expire Time in CodeIgniter 3

  <?php defined ( "BASEPATH" ) or exit ( "No direct script access allowed" ); use Firebase\JWT\ JWT ; use Firebase\JWT\ Key ; class RequestFifteen extends CI_Controller {     public function __construct ()     {         parent :: __construct ();     }     public function index ()     {         $key = "Fifteen_Key" ;         /*$data = [             //This is used in case of POST request to pass data             "username" =>  "user@3944",             "password" => "3228"         ];*/         //Set the expiration time to 2 hour from the current time         $issuedAt = time ();         $expirationTime = $issuedAt + 7200 ;     //jwt valid for 2 hour from the issued time ...