How to use php sessions?

php Add comments

<?php
// Use of session_register() is deprecated
$hello = "Hello world!";
session_register("hello");

// Use of $_SESSION is preferred, as of PHP 4.1.0
$_SESSION["var"] = "Setting this value to the global session variable 'var'.";

// The old way was to use $HTTP_SESSION_VARS
$HTTP_SESSION_VARS["message"] = "Hello world.";
?>

If session_start() was not called before this function is called, an implicit call to session_start() with no parameters will be made. $_SESSION does not mimic this behavior and requires session_start() before use.

Leave a Reply

You must be logged in to post a comment.

WebSite Powered by webHauser
Entries RSS Comments RSS Login