Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

weird php session problem .... totally stumped

  • 14-01-2006 10:31pm
    #1
    Registered Users, Registered Users 2 Posts: 673 ✭✭✭


    Hey,

    Ok, this is freaking me out. I have been setting up a site on my testing server and it all runs fine. I have now loaded it up onto my hosting account.

    When someone logs in with their username and password the current user is saved in the current session i.e. their name and so on. Once they have logged in their name is displayed on the screen.

    For some reason when the user clicks onto a new page the name that is displayed has changed to a different user (the user it changes to first is always the same one) then when you click on another link the name changes again (the second time it changes it always changes to the same user also). Then whenever i click on any further links the name stays at the new displayed name.

    This doesnt happen on the testing server with exactly the same scripts!!

    Anyone got an idea why this could be happening?

    Thanks


Comments

  • Registered Users, Registered Users 2 Posts: 849 ✭✭✭Cr8or


    Sounds like the page is cached in your broswer this often happens with php pages using sessions .. My guess is that you loged in as user X before and when you log in as user Y user X is still displayed. If this is the problem you can force the page to use nocache with headers ect.

    Try this on each session page. Dont ask where to put it or ask why your getting errors.. RTFM.

    [PHP]<?php
    header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
    ?> [/PHP]

    If not, it may be a problem with your sessions ie you do not kill sessions or the vars inside the session are not getting reset.


  • Subscribers Posts: 9,716 ✭✭✭CuLT


    Mmm, I'd favour the "not killing sessions properly" option.


  • Registered Users, Registered Users 2 Posts: 673 ✭✭✭Bananna man


    Well this is the first time ive used sessions on a site (Im only a learner!!) but it just doesnt make sense to me that it doesnt do this on my testing server with the exact same code and database.


  • Registered Users, Registered Users 2 Posts: 673 ✭✭✭Bananna man


    CuLT wrote:
    Mmm, I'd favour the "not killing sessions properly" option.

    Im not sure if it has anything to do with not killing old sessions properly. When i login first the the correct first name and second name appear (they are stored in the session as two seperate variables) then when i click a link it changes to the same user every time no matter what user i logged in with first off. Then when i click another link the first name goes back to the first name that should be logged in but the second name chages to another variable (the variable that it changes to is always the same no matter who you logged in as first). From this point on the name doesnt change again when you click on other links.

    Just a reminder, this doesnt happen on the testing server, which makes no sense to me!!!


  • Registered Users, Registered Users 2 Posts: 673 ✭✭✭Bananna man


    Just did a bit more investigating and it turns out that the $_SESSION doesnt change even though it is dealt with exactly the same as the $_SESSION and $_SESSION. This means i can do a work around and instead of calling on the session variables for the names i can just query the database where the $_SESSION = user_id but i would like to know why this is happening for future work i am doing.

    How could it be possible that the $_SESSION doesnt change and the others do and that this doesnt happen at all on my testing server????? :confused:


  • Advertisement
Advertisement