Tag: sessions
The extreme basics of php sessions
by admin on Nov.18, 2008, under PHP
Sessions are a wonderful thing, but they can be quite confusing to beginners.
Let’s say you want to get some input from your visitor and then store in in session variables, here’s the code:
<?
session_start();
if ($_POST['field_that_was_posted']) {
session_unregister(”session_field_name”);
$session_field_name = $_POST['field_that_was_posted'];
session_register(”session_field_name “);
}
?>
now you can call your session variable by using this string
<? echo $_SESSION['session_field_name']; ?>
just make sure you have session_start(); stacked on top of all the calls.
When you want to kill the session just call session_destroy();