Results 1 to 4 of 4

Thread: Session Tutorial...

  1. #1
    Join Date
    Jan 2007
    Location
    The stage
    Posts
    568
    Thanks
    23
    Thanked 6 Times in 6 Posts

    Default Session Tutorial...

    I Know I've asked for this before... but I really am not in the mood for getting the shovel and digging through this forum to find it...

    I was wondering if there were any really good tutorials on SESSIONS!
    I would love to learn sessions cuz I've heard they make life easier...

    Thanks!

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    There's nothing really to tell about sessions. To use sessions, you have to call:
    Code:
    session_start();
    at the top (very top, no HTML or whitespace before it or you'll get errors) of every page, then you can just read to and write from $_SESSION like any other associative array.

    Yes, they are quite handy.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Jan 2007
    Location
    The stage
    Posts
    568
    Thanks
    23
    Thanked 6 Times in 6 Posts

    Default

    So your saying I can do this:
    PHP Code:
    $input $_Session["Input"];
    //Instead of doing this:
    $input $_POST["Input"]; 
    If so that makes things easy
    *And yes I know as long as I have session start at the top...*

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Yup, that's right. You can write to it too (you can write to $_GET and $_POST as well, it's just usually not very useful):
    Code:
    $_SESSION['myvar'] = 5;
    Then, on a completely separate page (with session_start() of course), you can just do:
    Code:
    do_something_with($_SESSION['myvar']);
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

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