SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Jun 2001
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Session, please help

    Hello

    I have a login file with two fields: username and password
    Because I want to use variable username for other .php files so I declare session in login.php file as:

    login.php
    ===========
    <?
    session_start();
    session_register('username');
    ?>
    .....
    ... get username from a form.....
    ....get password ..................
    .........
    ============

    Now I want to assign the variable "username" of that user to a variable "name" in other get_name.php file as bellow.

    get_name.php
    ==============
    <?
    $name = $username;
    ?>

    However it did not work!!!!!.
    The variable "name" still did not know "username"


    Please help me what happen here

    Thank you very much for help.........
    johns

  2. #2
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    At the top of any file that you want to access session variables you have to have this statement (which most books on php do not make clear):

    session_start();

    I did the exact same thing as you when I first tried sessions.

  3. #3
    SitePoint Member
    Join Date
    Jun 2001
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thank you

    Many Thanks for your help
    john


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
  •