Hi. I just made a sample application at a website http://app.website.com, but it fails when I login into the system.
Locally, it is working. Upon tracing the bug, I found out that after the login code of $this->setState(‘roles’, $usersmodel->role); , the system succesfully sets the ‘roles’ to the user’s session (I echo the Yii::app()->user->getState(‘roles’) and Yii::app()->user->roles both). However, when I refresh the page, the state set would be gone.
I tried to locally see if my page somehow calls the log out url of my application, but it does not. Im not sure though if it has something to do with my HTAccess or something…
Here are my codes:
I added the class to the main configuration file
And I configured a controller to read my session
When I remove/disable the redirection part when the form is validated and user is logged in, I try to echo the roles, and it works. But if I refresh the page or go to other links, the roles would be gone and I would be GUEST again.
To help others out there with this issue, here are the steps I took:
I placed a fresh copy of Yii (generated from yiic locally then uploaded to webhost)
Logging in is not working in the fresh copy so I suspected that there is a session problem
I suspected that there is a problem with PHP’s Session so I placed a var_dump(session_start()) on each page. It then came out with an error
I then browsed through the PHP.ini file and found that the session path is not familiar to me, so I contacted the webhost(iPage - i know) and asked them to help me with the session. They fixed the session save path and everything works now.