Vlad777 / mit-stanford

MIT-Stanford MOOC mashup
2 stars 0 forks source link

After login, refreshing causes log out #14

Closed Vlad777 closed 11 years ago

Vlad777 commented 11 years ago

Not sure if this is the case with your original scripts. Since we've integrated them with the index page, refreshing causes user to be logged out, which is quite inconvenient. Do you think you can help with this?

reztic commented 11 years ago

Yea let me take a look.

reztic commented 11 years ago

Hmm, I see problems with the headers being sent before session_start(). Incase you were wondering, this is because we include html before the session_start(). Usually session_start() should be the first thing in a php script.

I changed the code, try it now. Iam not having problems with refreshing.

I tried with Chrome and Safari.

Vlad777 commented 11 years ago

I still see the problem on http://cs160.sjsu-cs.org/spring2013/sec2group3/index.php right now.

Alicedelic commented 11 years ago

Thanks for correcting the issue with sessionstart() not being the first thing. It did make the warning message go away I have no idea why I didn't get that warning message before _

I also still have the problem that logs me out when I refresh the page, on instructor's website. Shouldn't we look at whether his server php setting have session enabled?

reztic commented 11 years ago

It is enable. I uploaded a phpinfo.php up on the site. Its weird. I sometime get logged off, sometimes i stay logged in. But if you use my user_test.php to test the login, I stay logged in.

reztic commented 11 years ago

Oh. lol, there is whitespace a the end of pdo_connect.php. So its output whitespace. If you check the error_log, there are still warnings.

Alicedelic commented 11 years ago

Yeah wow I was just there to upload a phpinfo and I saw it was there. I will also look through the logs and see if anything helps.

reztic commented 11 years ago

Ok i removed whitespace from pdo_connect(). Seems to work. I tried in an Incognito tab.

Alicedelic commented 11 years ago

Maybe we should look through the logic of function_user.php and enable some debug? What is strange is that it works on local xampp environment...

reztic commented 11 years ago

Well i think our repo and website were out of sync. Because in the github, pdo_connect.php does not have whitespaces at the bottom. So if you just pulled the code from the repo, it will work. But if you didnt replace pdo_connect.php on the website you get a warning. I believe that this warning is saying that it cannot start the session. Since it cannot start the session, only the first page will appear to log in, cause you set all the variables, ie userid and username. But since Session was not correctly initiated these variables will not be saved between page refreshes.

The whitespace at the bottom of pdo_connect was causing the login issue.

Vlad777 commented 11 years ago

Big thumbs up for solving this one!

Alicedelic commented 11 years ago

Yes because we push things manually in the FTP and not the full blob from github. I also didn't know about that change about whitespace.

It works now! Thanks!

reztic commented 11 years ago

Cool. Iam going to close this then. We can open it or create a new one if there is an issue.