Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    Regular Coder
    Join Date
    Feb 2004
    Location
    Malaysia
    Posts
    175
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Http_session_vars

    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
    Last edited by mivec; 06-07-2007 at 05:00 PM.
    Warm Regards,
    Mivec

  • #2
    Regular Coder
    Join Date
    Jan 2007
    Posts
    217
    Thanks
    9
    Thanked 0 Times in 0 Posts
    it stores data in it. It's like a variable, only global and is stored in it until you quit the browser.

  • #3
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    $HTTP_SESSION_VARS is deprecated, revert to using the $_SESSION superglobal instead. Its easier since you don't need to register the values:
    PHP Code:
    <?php

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

    ?>
    Garbage collection should take care of the rest.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #4
    Senior Coder kbluhm's Avatar
    Join Date
    Apr 2007
    Location
    Philadelphia, PA, USA
    Posts
    1,509
    Thanks
    3
    Thanked 258 Times in 254 Posts
    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
    Last edited by kbluhm; 06-07-2007 at 09:10 PM.

  • #5
    Senior Coder whizard's Avatar
    Join Date
    Jan 2005
    Location
    Philadelphia, PA, USA
    Posts
    1,662
    Thanks
    14
    Thanked 76 Times in 76 Posts
    It's essentially a server side cookie

    HTH
    Dan
    PHP Tip: If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.

    Don't forget to save everyone time and mark your thread as Resolved :)

    "Also note that it is your responsibility to die() if necessary."

    DON'T USE THE MYSQL_ EXTENSION

  • #6
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Quote Originally Posted by whizard
    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.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #7
    Senior Coder kbluhm's Avatar
    Join Date
    Apr 2007
    Location
    Philadelphia, PA, USA
    Posts
    1,509
    Thanks
    3
    Thanked 258 Times in 254 Posts
    Ah, I misspoke, thanks for clearing that up.

  • #8
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    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.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #9
    Senior Coder whizard's Avatar
    Join Date
    Jan 2005
    Location
    Philadelphia, PA, USA
    Posts
    1,662
    Thanks
    14
    Thanked 76 Times in 76 Posts
    Quote Originally Posted by Fou-Lu View Post

    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



    Dan
    PHP Tip: If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.

    Don't forget to save everyone time and mark your thread as Resolved :)

    "Also note that it is your responsibility to die() if necessary."

    DON'T USE THE MYSQL_ EXTENSION

  • #10
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,642
    Thanks
    0
    Thanked 649 Times in 639 Posts
    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.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •