SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: Session

  1. #1
    SitePoint Evangelist
    Join Date
    Apr 2002
    Posts
    523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Session

    I would like to know about session. When should I use session.

    I saw other coding. He was using like this

    <php>
    if (isset($_session['uid'])
    {
    $user = $_session('user');
    echo" welcome back ".$user ."<br>.";
    }
    </php>

    I should have uid and user in my database.
    Please explain about it for me

    Thanks

  2. #2
    SitePoint Enthusiast Bartimeus's Avatar
    Join Date
    Dec 2000
    Location
    Norway, Trondheim
    Posts
    35
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sessions are used in order to track some variables from page to page.

    If you create a session and regsiter some variables in it you can access this information in your other sites.

    That code snipet you got there is a snippet that check if a variable called $uid is registered in the session. if it is it welcomes the user back. A typicall user autentication snippet.

    Let's say you got a user database with a uid primary key in it and some other fields with information about your user.

    You can then create a login box on one site and in the file that it posts to you can check with the database if this user exist. If it does you can start the session, register the uio to the session and redirect the user to another page.

    On that page you can use that snippet there to check if the user is one in your database.
    Bjarte S Karlsen
    Roleplayer and webdeveloper with a high nerd factor.


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
  •