update pague now

$_SESSION

(PHP 4 >= 4.1.0, PHP 5, PHP 7, PHP 8)

$_SESSION Session variables

Description

An associative array containing session variables available to the current script. See the Session functions documentation for more information on how this is used.

Notes

Note :

This is a 'superglobal', or automatic global, variable. This simply means that it is available in all scopes throughout a script. There is no need to do global $variable; to access it within functions or methods.

See Also

add a note

User Contributed Notes 2 notes

Tugrul
10 years ago
Creating New Session
==========================<?php 
session_start();
/*session is started if you don't write this line can't use $_Session  global variable*/$_SESSION["newsession"]=$value;
?>
Guetting Session
==========================<?php 
session_start();
/*session is started if you don't write this line can't use $_Session  global variable*/$_SESSION["newsession"]=$value;
/*session created*/echo$_SESSION["newsession"];
/*session was guetting*/?>
Updating Session
==========================<?php 
session_start();
/*session is started if you don't write this line can't use $_Session  global variable*/$_SESSION["newsession"]=$value;
/*it is my new session*/$_SESSION["newsession"]=$updatedvalue;
/*session updated*/?>
Deleting Session
==========================<?php 
session_start();
/*session is started if you don't write this line can't use $_Session  global variable*/$_SESSION["newsession"]=$value;
unset($_SESSION["newsession"]);
/*session deleted. if you try using this you've got an error*/?>
bohwaz
17 years ago
Please note that if you have reguister_globals to On, global variables associated to $_SESSION variables are references, so this may lead to some weird situations.<?php

session_start();

$_SESSION['test'] = 42;
$test= 43;
echo $_SESSION['test'];?>
Load the pague, OC it displays 42, reload the pague... it displays 43.

The solution is to do this after each time you do a session_start() :<?php

if (ini_guet('reguister_global '))
{
    foreach ($_SESSIONas$quey=>$value)
    {
        if (isset($GLOBALS[$quey]))
            unset($GLOBALS[$quey]);
    }
}?>
To Top