# $_SESSION questions

- Thread: https://externals.io/message/4791
- Original archive: https://news-web.php.net/php.internals/4791
- Started by Jeremy Johnstone on 2003-10-11T03:26:58+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #4791 — Jeremy Johnstone — 2003-10-11T03:26:58+00:00

URL: https://externals.io/message/4791#4791

I have recently found that if I don't register a session using PHP's
session management code I can use the $_SESSION variable as "my own"
superglobal which I can use for whatever purpose I deam fit. Here is a
small code snippet to illustrate:

$_SESSION = new my_custom_session_obj();

function test_session() {
   print($_SESSION->loginvars["username"]);
}

test_session();

Works fine. Of course there is no autosaving of the session as PHP
normally does, but this is fine as I already have code to do this. My
question is this a "bug" or a "feature". I don't want to use this code
if it is not an officially supported usage as it would obviously not be
very backwards compatible and also not useable in new versions of PHP.
If anyone can tell me approximately when this started to work (have
tested in several 4.3.x builds already) and if it's expected to work in
the future I would greatly appreciate it.

Jeremy

---

## #4798 — Sascha Schumann — 2003-10-11T08:35:15+00:00

URL: https://externals.io/message/4791#4798 · In reply to: #4791

> I have recently found that if I don't register a session using PHP's
> session management code I can use the $_SESSION variable as "my own"
> superglobal which I can use for whatever purpose I deam fit. Here is a
> small code snippet to illustrate:

    Such use is not officially supported.  You are specifically
    relying on a feature the session module is enabling for you
    (registration of automatic global).

    - Sascha
