My Way Create License Key For PHP Application

Seegatesite – Creating PHP license key for secure applications from software piracy. What do you feel if your paid application is used by people who do not have the right to use the application? of course, you are very disappointed and angry. I have experienced this some time ago. My POS Applications that I created in a few months, has been spread by people who do not have a right of usage because the application is not protected. So, an idea occurred to create software license in the form of a license key whenever the user doing the new installation a PHP application on the server locally or online. Here’s a simple way I protect the PHP application with a license key.

Basic concepts

My Way Create Simple Php Application License Key

The simple idea is in the header of the script will check if the license key is existing or not? if existing, whether the license key is valid or not. If invalid , the system will redirect users to the activation page to register first.

This activation code is checking the hard drive ID, so 1 license key is valid only for 1 hard drive. This method is effective for the offline application (intranet).


To create a license key code, I use some parameters as follows

  • Secret code : a key which is only owned by us as a developer.
  • Username : username of the person who has the right to use the application.
  • Password : the owner password who has the right to use the application.
  • Unique code : In this tutorial, used the hard drive ID as the unique code.

How to check hard drive ID using PHP

To detect the hard drive id in PHP there are 2 ways I do. That is to detect the hard drive id for the windows operating system and detect hard drive id Linux operating systems from PHP server.

Tutorial creates a simple license key on PHP application

Work Flow Tutorial Create License Key Php By Seegatesite

There are 2 sides in making the license key, i.e. from the client side (web application) and the server side (web activator).

Client Side (app folder)

1. Make a folder with name “app“.

2. Create a PHP file with name index.php and copy the following code

Explanation :

When the user open index.php page , the system will check if there is a license key file or not ? If no, then the user will be directed towards the activator page.

3. Create an HTML page with name activator.html and copy the following code

4. Create a PHP file with the name c_activator.php

Explanation :

The system will send the parameters needed by the server to establish the license key. The system will get the license key code on the server using  curl command.

After the license codes obtained from the server, the system will create a new file with the .key extension -> license_code.key

Build Secure License Key With Php

SERVER SIDE (webkey folder)

1. Create a folder with the name “webkey”

2. Create a file with the name index.php in the webkey folder and copy the following code

Explanation :

The server will accept the parameters sent by the client, then check each parameter are valid or not. The server will return the license code to the client, and the code will be processed by the client by creating a new file with .key extension.

Up here, you’ve finished making the simple license key using PHP. If you re running the code will be as the following video

Note, if you don’t encrypt your php files, all the above code would be futile anyway. Make sure you perform encryption on your php code using a reliable encryption. For a free encryption, I suggest you use encryption php file from

Tutorial creates a license key for PHP application is suitable for intranet applications or offline application. If you used online applications such as WordPress themes, plugins, and some tools supporting online applications, how to create the license key? I will discuss on the other occasions.

Please download the full code above at the following link

If there are suggestions and questions please leave a message in the comments below, I will be happy to assist you. So my quick tutorial how to create a license key for a PHP application may help you.

The following two tabs change content below.
This site is a personal Blog of Sigit Prasetya Nugroho, a Desktop developer and freelance web developer working in PHP, MySQL, WordPress.


 Add your comment
  1. lmao! i don’t understand these things..but what is the relation between this code and my software??!!!…i want to protect it with a license key or trial makes my software works only for a periode of time….and what’s mean “Updates” …..??? and is it these updates a good idea to protect my software.( my english is sucks hahahhaha don’t lought “…peace.

  2. hi, how can I release new license key and remove the previous license key.

  3. Hello i have question from your article which file i have to make in client file and which file i have to made in my server so i can give him a key to activate my product please reply me there

  4. Password : do not working !

Leave a Comment

Your email address will not be published.

Time limit is exhausted. Please reload CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.