After a long time again I am here to resolve my problem. I am much new to Codeigniter framework. I just started learning RESTful api's in CodeIgiter. Then I got to Know about that we can use JWT instead of Sessions. I am able to use the JWT and generated the token successfully. Now the problem here is, I want to verify the generated token for every request from the client. for example, this is the basic url or api, http://localhost/codeigniter/api/

Now I want to verify something like this:

http://localhost/codeigniter/api?token="here the generated token will come"

How do I implement it, using Codeigniter 3.x

I am using codeigniter-rest server for API calls, and php-jwt to generate tokens.


first create a helper from code https://github.com/rmcdaniel/angular-codeigniter-seed/blob/master/api/application/helpers/jwt_helper.php

then load or auto load this helper.

This will give you the token

helper_name::encode(data, secure_key) 

To verify you need to use


it will give you data which you have encoded or it will give you false if token is not valid.


Important Update:

I updated the repository to CodeIgniter 4. Developers who want to use CodeIgniter 3, use following command:

git checkout CI3

Original Answer:

I have created a repository which contains this code including helper class.

Since this is a sample code, I am not expecting any username or password.

GET auth token

URL: http://host/CodeIgniter-JWT-Sample/auth/token
Method: GET

Check decoded token

Method: POST
Header Key: Authorization
Value: Auth token generated in GET call

Your Answer

