Ness PHP Session Class
Required Namespace
  • Ness
    • Tool
      • Session

You can include this library to your code file by typing the below code;

use Ness\Tool\Session


About Session Class #top

Ness PHP has a light session class. You can use Ness PHP's session function to manage your session data.


Available Methods #top

__construct

$mysession = new Ness\Tool\Session("testing-session-class");
                        
Initialize class
Return Session Object
Parameters $prm String; Session Name



Create

 $mysession = new Ness\Tool\Session("testing-session-class");
 $mysession->Create("user_type","admin");
                         
Create new session.
Return Session Object
Parameters $prm String; Session ID
$prm2 String; Session Value



Delete

  $mysession = new Ness\Tool\Session("testing-session-class");
  $mysession->Create("user_type","admin");
  $mysession->Delete("user_type");
                          
Delete a session.
Return Bool
Parameters $prm String; Session ID



Clear

  $mysession = new Ness\Tool\Session("testing-session-class");
  $mysession->Create("user_type","admin");
  $mysession->Clear();
                          
Clear all sessions.
Return Void
Parameters None



Destroy

  $mysession = new Ness\Tool\Session("testing-session-class");
  $mysession->Create("user_type","admin");
  $mysession->Destroy();
                          
Destroy all sessions with php's session_destroy command.
Return Void
Parameters None



isAvailable

  $mysession = new Ness\Tool\Session("testing-session-class");
  $mysession->Create("user_type","admin");
  

    if($mysession->isAvailable("user_type")){
        echo "session is set.";
    }else{
        echo "Not Set";
    }
                          
Check if session is set.
Return Bool
Parameters $prm String; Session ID



GetName & SetName

  $mysession = new Ness\Tool\Session("testing-session-class");
  $mysession->Create("user_type","admin");
  echo $mysession->getName();
                          
Using this two functions you can set a session class name get session class name. GetName @return string.
Return String
Parameters None




$mysession = new Ness\Tool\Session("testing-session-class");
$mysession->Create("user_type","admin");
$mysession->setName("other-name-for-class");
                        
Set new name to session
Return Void
Parameters $prm String; New name of session class



CreateMultiple

  $mysession = new Ness\Tool\Session("testing-session-class");
  $mysession->Create("user_type","admin");
  $mysession->CreateMultiple(array("user_type"=>"admin", "login_time"=>"14:30"));
                          
Create multiple sessions with one line.
Return Void
Parameters $prm Array; Set multiple session data



DeleteMultiple

  $mysession = new Ness\Tool\Session("testing-session-class");
  $mysession->Create("user_type","admin");
  $mysession->DeleteMultiple(array("user_type", "login_time"));
                          
Delete multiple session data with arrays and keys.
Return Bool
Parameters $prm Array; Session id's as array



Regenerate

  $mysession = new Ness\Tool\Session("testing-session-class");
  $mysession->Regenerate(false);
                          
Generate new id for current session class.
Return Void
Parameters $prm Bool; true if old session data will be stored.