HomeMenu
Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

session_start

Description

The session_start of Session for PHP starts a new or resumes an existing session.

Syntax

session_start(
    array $options = []
): bool

Parameters

options

If provided, this is an associative array of options that will override the currently set session configuration directives. The keys should not include the session. prefix.

In addition to the normal set of configuration directives, a read_and_close option may also be provided. If set to true, this will result in the session being closed immediately after being read, thereby avoiding unnecessary locking if the session data won't be changed.

Return

Returns true if a session was successfully started, otherwise false.

Examples

1 · void

<?

$return = session_start();

var_export($return);
true

2 · options

<?

$options =
[
    "name" => "myname"
];

$return = session_start($options);

var_export($return);
true

3 · options · read_and_close

<?

$options =
[
    "name" => "myname",
    "read_and_close" => true
];

$return = session_start($options);

var_export($return);
true

4 · page1 page2

<?

//page1

session_start();

$_SESSION["mykey"] = "myvalue";

<?

//page2

session_start();

echo $_SESSION["mykey"];