PHP Classes

PHP User Identification: Get and set user identification details

Recommend this page to a friend!
  Info   View files Example   Demos   View files View files (2)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 498 All time: 5,830 This week: 660Up
Version License PHP version Categories
user-identification 1.0GNU General Publi...5.3PHP 5, User Management
Description 

Author

This class can get and set user identification details.

It can retrieve details about the user such its geographic location based the IP address obtained from ipinfo.io, city, country, preferred language, host name, etc..

The details are stored in session variables. Applications can also set other custom variables such as the authenticated user name, personal name, etc..

Picture of Ricky Scotti
  Performance   Level  
Name: Ricky Scotti <contact>
Classes: 3 packages by
Country: Switzerland Switzerland
Age: 44
All time rank: 190121 in Switzerland Switzerland
Week rank: 360 Up6 in Switzerland Switzerland Up

Recommendations

I need a PHP class for professional login system
Create a professional login system

Example

<?php
/**
 * Created by Riccardo Scotti.
 * User: Riccardo Scotti
 * Date: 18/08/15
 */


/*
 * IMPORTANT!! ob_start(); is essential for unset cookies. If you don't use this two method you can comment this line.
 * Methods: unSetUser() destroyUser()
 */

ob_start();

    require_once(
'./lib/class/class.users.php');

   
//class to call
   
$user= new USERS\Identify();

   
/* AUTO LANGUAGE DETECTED BY BROWSER */
   
echo 'Language: '.$user->getUser('_language').'<br>'.PHP_EOL;

   
/* IF IpLocation = true; SET VALUE CONSTANT IN CLASS*/
   
echo 'City: '.$user->getUser('_city').'<br>'.PHP_EOL;
    echo
'IP: '.$user->getUser('_ip').'<br>'.PHP_EOL;
    echo
'Hostname: '.$user->getUser('_hostname').'<br>'.PHP_EOL;
    echo
'Country: '.$user->getUser('_country').'<br>'.PHP_EOL;
    echo
'Localization: '.$user->getUser('_localization').'<br>'.PHP_EOL;
   
/**/

   
echo '<hr>'.PHP_EOL;
    echo
'Corrected call to the Class:';
    echo
'<br>'.PHP_EOL;

    echo
'Set var UserName already setted in class array :';
   
$user->setUser('UserName','Ricky Scotti');
    echo
$user->getUser('UserName').'<br>'.PHP_EOL;

    echo
'Create var "author" will not be recorded in cookies, set and display:';
   
$user->createParameter('author',0); //parameter 0-1 for record in cookies
   
$user->setUser('author','Ricky Scotti');
    echo
$user->getUser('author').'<br>'.PHP_EOL;

    echo
'Create var "webmaster" will be recorded in cookies, set and display:';
   
$user->createParameter('webmaster',1); //parameter 0-1 for record in cookies
   
$user->setUser('webmaster','Ricky Scotti');
    echo
$user->getUser('webmaster').'<br>'.PHP_EOL;

    echo
'Change language:';
   
$user->setLanguage('fr');
    echo
$user->getUser('_language').'<br>'.PHP_EOL;

    echo
'<hr>'.PHP_EOL;
    echo
'Wronged call to class:';
    echo
'<br>'.PHP_EOL;

   
/* SOME ERROR */
   
if($user->createParameter('UserName',0)===false){
        echo
'Var already exist or private! Not Set<br>'.PHP_EOL;
    };

    if(
$user->setUser('_language',"fr")===false){
        echo
'Var not found or private!<br>'.PHP_EOL;
    };

    if(
$user->getUser('test')===false){
        echo
'Var not found!<br>'.PHP_EOL;
    };
   
/*END ERROR */

    /* SET VERIFY USER */
    /* For example after a verified login, uncomment line under*/
    //$user->loginVerifiedUser();

   
if ($user->userIdentified()==1){
       
/*USER VERIFIED IN THIS SESSION*/
       
echo 'User Verified<br>'.PHP_EOL;
    } else {
       
/*USER not VERIFIED IN THIS SESSION*/
       
echo 'User Not Verified<br>'.PHP_EOL;
    }

   
/* UNSET VERIFY USER */
    /* For example after a logoff, uncomment line under */
    //$user->unSetUser();



    /* ALERT: DELETE COOKIES AND UNSET SESSION */
    //$user->destroyUser();


  ExampleExternal page  
  Files folder image Files  
File Role Description
Files folder imagelib (1 directory)
Plain text file session.php Example Example file

  Files folder image Files  /  lib  
File Role Description
Files folder imageclass (1 file)

  Files folder image Files  /  lib  /  class  
File Role Description
  Plain text file class.users.php Class Class file

 Version Control Unique User Downloads Download Rankings  
 0%
Total:498
This week:0
All time:5,830
This week:660Up