Skip to content
Snippets Groups Projects
Commit fb5a654e authored by dharaneesh . r ravi's avatar dharaneesh . r ravi
Browse files

introduction to session

parent 49f43452
No related branches found
No related tags found
No related merge requests found
<?php
class session {
public static function start() {
session_start();
}
public static function unset() {
session_unset();
}
public static function destroy() {
session_destroy();
}
public static function set($key, $value) {
$_SESSION[$key] = $value;
}
public static function delete($key) {
unset($_SESSION[$key]);
}
public static function isset($key) {
return isset($_SESSION[$key]);
}
public static function get($key, $default = false) {
if (Session::isset($key)) {
return $_SESSION[$key];
} else {
return $default;
}
}
}
......@@ -3,6 +3,8 @@
include_once "includes/Mic.class.php";
include_once "includes/Database.class.php";
include_once "includes/User.class.php";
include_once "includes/Session.class.php";
Session::start();
//this function load all the file
function load_templates($name) {
// print("including $name.php");
......
sg.php 0 → 100644
<pre>
<?php
include "libs/load.php";
// print("_SERVER\n");
// print_r($_SERVER);
// print("_GET\n");
// print_r($_GET);
// print("_POST\n");
// print_r($_POST);
// print("_FILES\n");
// print_r($_FILES);
// print("_COOKIE\n");
// print_r($_COOKIE);
// print("_SESSION");
// print_r($_SESSION);
/**
*
*before the object class is used
*/
// if(isset($_GET['clear'])){
// print("clearing.....");
// session_unset();
// }
// if(isset($_SESSION['a']))
// {
// print("\na already exists... value :$_SESSION[a]");
// }
// else
// {
// $_SESSION['a']=time();
// print("\nassigning new value ...:$_SESSION[a]");
// }
// if(isset($_GET['destroy']))
// {
// print("destroying.....");
// session_destroy();
// }
/**
* after the object class is used
*/
print("_SESSION");
print_r($_SESSION);
if(isset($_GET['clear'])){
print("clearing.....");
Session::unset();
}
if(Session::isset('a'))
{
print("\na already exists... value :".Session::get('a')."\n");
}
else
{
Session::set('a',time());
print("\nassigning new value ...:".Session::get('a')."\n");
}
if(isset($_GET['destroy']))
{
print("destroying.....");
Session::destroy();
}
?>
</pre>
\ No newline at end of file
<?php
include "libs/load.php";
// print("_SERVER\n");
// print_r($_SERVER);
// print("_GET\n");
// print_r($_GET);
// print("_POST\n");
// print_r($_POST);
// print("_FILES\n");
// print_r($_FILES);
// print("_COOKIE\n");
// print_r($_COOKIE);
// testing the signup function
// if (signup("sam", "password", "sam@123", "6369239993")) {
// echo "success";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment