Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2005
    Posts
    203

    Arrow Unanswered: how to pass user info to diffrent pages using sessions?

    Hi all i wonder how i can pass user information such as login name to diffrent pages using sessions. My intention is that i want in diffrent pages the php pages automatically knows who is using the page and where user log name is necessary it is avaliable by just doing echo $username or using $username in queries.Furthermore, i want the sessions some how expire within 15 min or so.I be happy if an expert show me how i can create sessions and how to use it in php pages for above purpuse. Thanks

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    what have you tried so far?

    theoretically what you want to achieve should be realively easy.

    there are other ways of handling the time limit but there is nothing to onerous in what you want to do.
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Apr 2005
    Location
    Baltimore, MD
    Posts
    297
    PHP Code:
    $_SESSION['username'] = $var;

    echo 
    $_SESSION['username']; 
    http://fr.php.net/manual/en/ref.session.php

    check your web server configuration to handle session expiration.

  4. #4
    Join Date
    Apr 2005
    Posts
    203
    Quote Originally Posted by jfulton
    PHP Code:
    $_SESSION['username'] = $var;

    echo 
    $_SESSION['username']; 
    http://fr.php.net/manual/en/ref.session.php

    check your web server configuration to handle session expiration.
    Many thanks for u reply. Do u mean in my first page i do some thing like this at the top of page :
    Code:
    SESSION_START(); 
    $_SESSION['username'] = $var
    when i go to next page shoud i pass variable or some thing ? how to use the variable stored in session in 2 page ? how to call it ?Thanks

  5. #5
    Join Date
    Apr 2005
    Location
    Baltimore, MD
    Posts
    297
    You can access the session variables from any page, you don't need to pass it through forms or anything. The session object is accessible for the length of the user's session.
    PHP Code:
    //to set the variable...
    $_SESSION['username'] = $var;
    //to accesss/print the variable
    echo $_SESSION['username']; 
    Also, depending on the php.ini settings, I thinkn you may not need to call session_start. But I guess it can't hurt?

Posting Permissions

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