php - Yii Session Variable -
I am working with session variables in the YII framework.
I created session variables in Site Controller
As
Public Function Authentication () {$ user = UserSignupForm :: model () - & Gt; FindByAttributes (array ('emailid' => = this- & gt; username)); If ($ user === empty) $ this- & gt; ErrorCode = self :: ERROR_USERNAME_INVALID; And if ($ user- & gt; password! == ($ this- & gt; password)) $ this- & gt; ErrorCode = self :: ERROR_PASSWORD_INVALID; Else {$ connection = Yii :: app () - & gt; Db; $ Sql = "Choose roles from the ralinom, where the role has been played (to play a role from Uire's where the user-in-the-user select from user iFO, where e-mail id = 'user-> e-mail id');"; $ Command = $ connection- & gt; CreateCommand ($ sql); $ Roles = $ command- & gt; Query still (); // $ this- & gt; Setstate ('roles', $ roles ['0'] ['theft']); // $ this- & gt; Setstate ('user', $ user- & gt; username); $ This- & gt; ErrorCode = self: ERROR_NONE; Yii :: app () - & gt; Session ['role1'] = $ roles ['0'] ['rolename']; ['Role1'] session ;; & Gt - $ Yii :: App () s =}} I am getting the value of the session within this controller.
But I am redirecting another controller. Its session variable has not been placed and it does not have a distinction.
I think this link can help you: < P>
Basically:
- Enter the ID from the session:
- Extension of CWebUser or other visible folder in component to create a class web application Something like this:
Class WebUser did not increase the CDB user {// store model to replicate the query. Private $ _model // Return name first // it's Yii :: app () -> & gt; User- & gt; Use first_name function getFirst_Name () {$ user = $ this- & gt; Load User (Yii: App () -> User- & gt; ID); $ User- & gt; Return to first_name; } // Return the first name // it's Yii :: app () -> & gt; User- & gt; First_name function getRole1 () {$ user = $ this- & gt; Load user (accessed via Yii :: app () -> User-> ID); # Role role return $ role; # Rotor roll} // load user model Secure function loadUser ($ id = null) {if ($ this-> _model === faucet) {if ($ id! == null) $ this- & gt; _model = User :: model () - & gt; FindByPk ($ id); } $ $ -> Modell; }}? & Gt;
Comments
Post a Comment