SitePoint Sponsor

User Tag List

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

    session please help again

    Hello all again.

    I got same help but there is new problem

    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 and show username's table as bellow:

    get_name.php
    ==============
    <?

    session_start(); //to get username from login file
    $name = $username;
    ......
    ...Show username's TABLE....
    ......
    ?>

    It is work well.

    The new problem here is when I return "BACK" to previous login page and I login as another user (different with previous one), I went to the same page of the previous user, (that means it still show previous user's table)

    I thought that I will use session_destroy() function like this:

    login.php
    ===========
    <?

    session_destroy(); //destroy previous session
    session_start(); //start new session
    session_register('username');

    ?>


    However, it still the same, after I login, I still went to the previous user's page !!!!!!!!!!!!!!!!.


    (Please note that, I may use the same username variable for other pages)

    Could you please help

    Many thanks
    john

  2. #2
    SitePoint Zealot jonsteele's Avatar
    Join Date
    Jan 2001
    Location
    Toronto
    Posts
    106
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try refreshing the page, or setting the page to nocache in the meta headers.

    Also, session_destroy() has proved to be unreliable in the past. Try setting the session variable to null or " ".

    Good luck,
    Jon.

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

    still not work

    Thanks but it still not work

  4. #4
    Talk to the /dev/null Theiggsta's Avatar
    Join Date
    Mar 2001
    Location
    Tampa, FL
    Posts
    376
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you should have a logout page that will session_destroy() and also put this on access denied pages, so that way no one has anything that may involve a security risk.

    try that out, thats how I do it.
    Aaron "Theiggsta" Kalin
    Pixel Martini
    Ruby and Rails Developer

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

    I want to "back"

    Hello
    Yes, I can have a logout.page but what I want is that I can "BACK" to previous login page event I do not logout yet. So I can login as another user.
    Thanks
    johns


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
  •