Sessions

The session class can be used to set, get, delete and to check if a session exists.

Class: Session

In this table you'll find information about the different methods you can use and what kind of data can be passed as an argument.

Method Arg Type Expect
set() 1 string session name
set() 2 string session value
get() 1 string session name
exists() 1 string session name
delete() 1 string session name

Setting a session

The first argument should be the name of the session and the second argument the session value.


<?php

  use core\Session;

  Session::set('name', 'value');         

Getting a session

To get a session value, call the get function method. The argument should be the session name.


<?php

  use core\Session;
  
  Session::get('name');            

Checking if a session exists

To check if a session exists, call the exists function method. The argument should be the session name.


<?php
                
  use core\Session;
  
  Session::exists('name');      

Deleting a session

To delete a session, call the delete function method. The argument should be the session name.


<?php

  use core\Session;          
  
  Session::delete('name');