...

View Full Version : Http_session_vars



mivec
06-07-2007, 03:55 PM
hie all,
i am quite new to php so i would like to ask you gurus that what does this function do? : $HTTP_SESSION_VARS['username']

what does it do? and how is it used? i went through the php online help but there are none that seems to explain this

pls help...thanking u in advance

ole90
06-07-2007, 04:03 PM
it stores data in it. It's like a variable, only global and is stored in it until you quit the browser.

Fou-Lu
06-07-2007, 06:43 PM
$HTTP_SESSION_VARS is deprecated, revert to using the $_SESSION superglobal instead. Its easier since you don't need to register the values:


<?php

session_start();
$_SESSION['username'] = "MyName";

?>

Garbage collection should take care of the rest.

kbluhm
06-07-2007, 07:58 PM
All superglobals were shortened some time ago.

Whenever you see:
$HTTP_XXX_VARS

...it is now:
$_XXX

...in most cases ($_FILES is an exception).

Here's the list:
http://www.php.net/variables.predefined

whizard
06-08-2007, 04:15 AM
It's essentially a server side cookie

HTH
Dan

Fou-Lu
06-08-2007, 03:22 PM
It's essentially a server side cookie

HTH
Dan
:)
Thats the best explaination I've ever heard, nice, easy and true



All superglobals were shortened some time ago.

That is not true, HTTP_*_VARS are types of registered long arrays, and are not equivilent to a superglobal. The data used for the long arrays is extracted (via pass by value if I'm not mistaken) to the HTTP_*_VARS for backwards compatability.
You can test this by creating a function and attempting to use a HTTP_*_VAR without globalizing it - it will fail and is therefore not a superglobal.

kbluhm
06-08-2007, 03:32 PM
Ah, I misspoke, thanks for clearing that up.

Fou-Lu
06-08-2007, 03:37 PM
np mate, HTTP_*_VARS are so rarely used most people completely forget about that.
I just specifically remember this aspect since I started coding in php 4.1. Superglobals came out just after and I first learned that if you squeeze the values of the long arrays into the superglobals, they do not inherit a superglobal scope. What a pain that time was, lol.

whizard
06-09-2007, 06:28 AM
:)
Thats the best explaination I've ever heard, nice, easy and true


Good to receive confirmation on that... I was pretty sure that was right, based on my knowledge of sessions, but it seemed so simple I was a little worried when I wrote it that I might be missing something

:D

Dan

felgall
06-09-2007, 06:44 AM
The session id will either be stored in a real cookie or passed in the querystring on the end of the URL depending on how you have sessions configured and whether your visitor allows cookies. All of the rest of the data is stored in a file on the server.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum