adam.clarkson Posted March 7, 2007 Share Posted March 7, 2007 Hey I am having quite a strange error with sessioning. I am using my University webspace to host a website and simply want to be able to utilise an admin login system so that I am able to edit certain sections of the web site, similar format to Wiki! However, the session variables are initialised ok on successful login, and then all subsequent pages use a header include, which checks for the existance of the session variable and sets an admin status (true or null) The rest of the code then checks this variable to see whether the edit links are shown for certain areas, and also makes sure that if the direct link is typed in, the headerfile contains the admin variable, other wise it denys access. The problem is that pages do not always recognise the session. To clarify I can log in, go to a page, not see the edit buttons, press refresh and they appear, refresh a couple more times and they disappear, refresh again and they may come back etc etc etc. It is a very intermittent problem with regard to when they appear or do not. I decided to write a simple test file to see if this still occured with the following code: <?php session_start(); if ($_SESSION['user']){ //if the session variable set on login (ignoring the aforementioned header file) echo "hello"; }else{ echo "goodbye"; } ?> on testing this program by loging in accessing this page and then pressing refresh numerous times, I recieved the following outputs: goodbye hello hello hello goodbye hello hello goodbye goodbye hello goodbye as you can see it tends to be rather random. This is proving to be quite a problem as it is denying me access to certain pages which I should be able to reach at times. I do not think that this is related to a session expiration, due to the fact that after a negative result has been received, apositive may follow, indicating that the session, and its variable are active. I really really need help with this guys, its driving me insane, and the launch date of the website into the public domain is pretty soon! Many many thanks in advance (sorry for the long post!) Adam. Quote Link to comment https://forums.phpfreaks.com/topic/41607-strange-session-error/ Share on other sites More sharing options...
vbnullchar Posted March 7, 2007 Share Posted March 7, 2007 uhm, <?php session_start(); if (isset($_SESSION['user'])){ //if the session variable set on login (ignoring the aforementioned header file) echo "hello"; }else{ echo "goodbye"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/41607-strange-session-error/#findComment-201585 Share on other sites More sharing options...
adam.clarkson Posted March 7, 2007 Author Share Posted March 7, 2007 thanks for the reply, still same thing is happening I'm afraid Could it be something related to the way in which I am initialising the variable I simply use session_start() (at the beginning of the page) then $_SESSION['user'] = "admin"; where it is required ? Quote Link to comment https://forums.phpfreaks.com/topic/41607-strange-session-error/#findComment-201587 Share on other sites More sharing options...
adam.clarkson Posted March 10, 2007 Author Share Posted March 10, 2007 hey, can no one out there help? Quote Link to comment https://forums.phpfreaks.com/topic/41607-strange-session-error/#findComment-204547 Share on other sites More sharing options...
per1os Posted March 10, 2007 Share Posted March 10, 2007 Sounds like there is a problem in the session area of the server. What is the server specs, IE php version, apache version etc.? My server, using that same script mine works just fine and dandy. Seems to be a server issue. --FrosT Quote Link to comment https://forums.phpfreaks.com/topic/41607-strange-session-error/#findComment-204549 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.