Set Cookies Get Cookies Delete Cookies with PHP

Cookies are small files created by server on a user computer, cookies are primarily used to store little information about anything, and when user visits your website next time the information stored in cookies can be retrieved and used in various purpose.

Check CURL is available using PHP

If you need to check whether curl is available in a web server, you can use snippet below to check available curl. The code below will check if curl is available and enabled in the web server. [cc lang=”php”] [/cc] Usage : [cc lang=”php”] [/cc]

Generate Random String Using PHP

The PHP snippet below generates a random string from given characters [0-9][a-z][A-Z]. You can just copy and use this PHP snippet in your projects. 123456789101112131415161718<?php function genRndString($length = 10, $chars = '1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ') {     if($length > 0)     {         $len_chars = (strlen($chars) - 1);         $the_chars = $chars{rand(0, $len_chars)};         for ($i = 1; $i < $length; $i = strlen($the_chars))         {             $r = $chars{rand(0, $len_chars)};             if ($r != $the_chars{$i - 1}) $the_chars .=  $r;         }         return $the_chars;     } } ?> Usage: 123<?php echo genRndString(); ?>

301 Redirect htaccess examples

Sometimes we need to change URL of pages, but it’s a risky task, because if your pages are already indexed in search engines, you will loose not only visitors but also ranking. Your indexed URLs will start to disappear one by one, forcing you to start from scratch again. But with htaccess you can easily redirect your visitors as well as search engine bots to new location safely.