-
-
Save sumonst21/33998b9252f98ba6e06edca9eadd980a to your computer and use it in GitHub Desktop.
PHPSESSID Helper functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function decode_session($data){ | |
$temp = $_SESSION; | |
session_decode($data); | |
$out = $_SESSION; | |
$_SESSION = $temp; | |
return $out; | |
} | |
function encode_session($data){ | |
$temp = $_SESSION; | |
$_SESSION = $data; | |
$out = session_encode(); | |
$_SESSION = $temp; | |
return $out; | |
} | |
function delete_session($id){ | |
$session_file = session_save_path() . "sess_" . $id; | |
if (file_exists($session_file)) { | |
return unlink($session_file); | |
} else { | |
return -1; | |
} | |
} | |
function overwite_session($session_id, $data){ | |
$sess = session_save_path() . "sess_" . $session_id; | |
if (file_exists($sess)) { | |
$sessionFile = fopen($sess, "w"); | |
if (is_writable($sess)) { | |
fwrite($sessionFile, encode_session($data)); | |
} | |
} | |
} | |
function get_session_data($hash){ | |
$file = session_save_path() . "sess_" . $hash; | |
if (file_exists($file)) { | |
return decode_session(file_get_contents($file)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment