Page 2 of 2 FirstFirst 12
Results 11 to 14 of 14

Thread: lost in PHP session

  1. #11
    Join Date
    Apr 2008
    Location
    Limoges, France
    Posts
    395
    Thanks
    13
    Thanked 61 Times in 61 Posts

    Default

    Get rid of session_write_close();

    What exactly is happening to make you think your session is lost?

    Are you trying to use your session variables after a refresh and they don't work?

    Try this:

    After you set your session for username, put

    Code:
    echo $_SESSION['CurrentUser'];
    somewhere on the page. This will display the username on the page. Hit refresh and see if it is still displayed.

    If it is still displayed, then you'll know that your problem is somewhere else.

    Post more of your code too. You might have a problem, but it isn't in the code you have posted.

    Good Luck!

  2. The Following User Says Thank You to JasonDFR For This Useful Post:

    sfchun (11-22-2008)

  3. #12
    Join Date
    Apr 2008
    Posts
    58
    Thanks
    22
    Thanked 0 Times in 0 Posts

    Default

    I think you put the finger where it hurts !

    my problem is that the html code in index.php is not generated by php !
    I did not think about this but as i'm not testing if $_SESSION variables are available at the page load (as it is html code) , it replace the display and shows again the login screen ... but the session is still running !

    thanks a lot !
    So now i know i should generate/call all my html code using php.
    Last edited by sfchun; 11-22-2008 at 09:27 AM.

  4. #13
    Join Date
    Apr 2008
    Location
    Limoges, France
    Posts
    395
    Thanks
    13
    Thanked 61 Times in 61 Posts

    Default

    I'm glad you found the problem, but you don't have to use php to generate all your code! And I don't think you should.

    You talked about a login screen being displayed when the user is logged in?

    I'm assuming it shouldn't be displayed when the user is logged in?

    Check out this thread:

    http://www.dynamicdrive.com/forums/s...ad.php?t=37942

    In the third post I posted some code. See how the <?php tags open and then close ?> You can use this technique throughout your page, only putting php where you need it.

    Take a minute to understand what is going on in that code and I think it will help you a lot!

    Good luck!

    Jason

  5. #14
    Join Date
    Apr 2008
    Posts
    58
    Thanks
    22
    Thanked 0 Times in 0 Posts

    Default

    Yes i understand well ^^

    i said generated, cause i have part of my page which should be hide or display following who is loging in ...
    Only this part should be done through php =P

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
  •