💻
Code Zero Project
  • introduction
  • Welcome
  • getting started
    • apa itu mini mvc php native
    • Installation
  • architecture consept
  • database
    • PDO
    • connection
    • migrations
    • query builder
    • result database
  • basic
    • models
    • controller
    • view
    • routing
    • markdown
  • helper
    • session
    • input
    • maintenance
    • debug
    • waktu
    • agent
    • email
    • get_rest_api
    • upload directory
    • asset
    • 404
    • redirect
    • random file name
    • url
    • slug
    • upload files
    • read markdown
    • Security
  • frontend
    • basic html
  • libraries
  • science
    • mathecmatic
    • ML
  • command shell
  • API
  • donation
  • about
Powered by GitBook
On this page
  • session start
  • session destroy
  • make session
  • this session
  1. helper

session

membuat helper untuk membuat session menggunakan build function

session start

session start() untuk mengaktifkan session

panggil session_start() pada method contructor untuk mengaktifkan session pada setiap controllernya.

public function __construct()
{
	// code here
	start_session();
}

session destroy

session_destroy() untuk mendestroy session atau menghapus session yang telah dibuat. atau bisa digunakan untuk method logout

public function logout()
{
	// code here
	session_destroy();
	redirect("login");
}

make session

make_session() untuk membuat session.

public function auth()
{
	// config session
	$session = [
		"username" => $_POST["username"],
		"login" => true,
	];
	
	// buat session
	make_session($session);
	
	// redirect session
	redirect("home");
}

this session

this_session() untuk melihat debug atau isi dari session

public function home()
{
	// config session
	this_session(); // return debug session bentuk array
	
}

hasilnya akan seperti ini :

"username" => "username",
"login" => true,
"_minimvc_session" => "ashdbjhbxzjgc1287gasda", // generate random
PrevioushelperNextinput

Last updated 3 years ago