Accessing Yii auth from non-yii php

This is my first post and i’d like to say first off that I think Yii is a very good framework and I have used it for quite a few projects now with success.

I have a question regarding the user/auth mechanism. I am transitioning a site from vanilla php to Yii, and first off I am converting the members section. Everything works well but there is one thing I cannot figure out how to do. Basically, once a member signs in, the “Login” link should change to “Logout (username)” throughout the site. The problem I am having is that I cannot see a way to access the user’s status and login details (set via Yii login) through plain php.

The way it is setup currently is something like this:


    if (isset($_SESSION['loggedIn'] && $_SESSION['loggedIn'] === '1') {

        echo '<a href="/logout.php">Logout ('.getCurrentUsername().')</a>';

    else {

        echo '<a href="/login.php">Login</a>';



Is there a way to include some core Yii files to be able to access the CWebUser object? This would enable me to transition the frontend to Yii page-by-page.

Thanks in advance.


I think I have it solved. My idea is as follows:



if file exists and is php file


pass request to yii entry script with catchAllRequest CWebApplication setting


load php file in controller and use Yii::app()->getUser() in existing php security check functions.

I’ll try this out when I get to work tomorrow.

I just tried this and it does work. The catchAllRequest property actually belongs to CWebApplication and not CUrlManager so I changed that above in case anyone is looking for a similar solution.

are you looking for smth like


Yeah thanks I was looking for a way to be able to access that via an old site where I am changing the security functions to be run through Yii.