<p>You probably have a plugin which is listening to the <code>userSession.onLogin</code> event and trying to access the current user from the session.</p>

<p>The solution is for the plugin developer to wrap the event listener to ignore console sessions like this:</p>

<pre><code>    if(!craft()-&gt;isConsole())
    {
        craft()-&gt;on('userSession.onLogin',
            [
                craft()-&gt;market_customer,
                'loginHandler'
            ]
        );
    }
</code></pre>

CC BY-SA 3.0
2015-09-04T09:39:22.767Z
2015-09-04T09:39:22.767Z
Luke Holder
<p>None of the craft core console commands to work.
For example: <code>./yiic querygen all My_MyRecord</code> produces an error which includes mention of <code>session</code>?</p>

<p>How do I get craft console commands working again?</p>

<console>
Running a console command produces an error mentioning sessions. How do I resolve?
# Running a console command produces an error mentioning sessions. How do I resolve?

(Asked by: username_0 on 2015-09-04)

None of the craft core console commands to work.
For example: `./yiic querygen all My_MyRecord` produces an error which includes mention of `session`?

How do I get craft console commands working again?

**Tags:** console

---

## 1 answers

### Answer by username_0 on 2015-09-04. Score: 1 | Accepted answer

You probably have a plugin which is listening to the userSession.onLogin event and trying to access the current user from the session.
The solution is for the plugin developer to wrap the event listener to ignore console sessions like this:
    if(!craft()->isConsole())
    {
        craft()->on('userSession.onLogin',
            [
                craft()->market_customer,
                'loginHandler'
            ]
        );
    }


---

