Snap Builder Public Codes Library
Snap | Generators | Login | Browse | Search | Enter Code | Export Snap Builder Public Codes Library

 

Category: PHP Codes Library >> Cookies >> Test Cookies Enabled


Code Snippet </> Info


Snippet Name: Test Cookies Enabled

Description: Test if the visitor to your website has cookies enabled and print appropriate message.

Note: Read script notes for easy setup.

Author: Snap Builder <snippets@snapbuilder.com>

Last Modified: 2019-12-14 01:20:29

Language: php

Highlight Mode: html

Copy Codes: Use Free Notepad ++
Bookmark and Share

Snap HTML Code Editor:
Paste the source code, make changes and instantly see it in live preview.
Snap HTML Code Editor


  About Copying
Copied To Clipboard!

<?php function test_cookies_enabled(){ // Create the test cookie. $success = setcookie("SnapBuilderTest","Testing cookies"); // If setcookie was successful, $success will be TRUE. // Otherwise, it will be FALSE. // Unset our cookie and return the result. setcookie("SnapBuilderTest","",time()-60); return $success; } $cookies = test_cookies_enabled(); if($cookies) // set message for enabled cookies below print "Okay, cookies are enabled!"; else // set message for disabled cookies below print "Oh No! Cookies are not enabled!"; ?>


[ Snippet Options ]

 

© 2002 -  Snap Builder Public Codes Library