We’re looking to perform server-side login without any modules, etc. We’ve tried different PHP techniques, but get errors like “unauthorized request” (slight variation depending on what method we tried). We’re trying to do this in a regular php-enabled template using some of the hooks we saw in the dev documentation, but nothing seems to return. We are creating these users on the fly with SQL statements successfully, but we’re stumped on the login side. We can do this with ajax, but we’re trying to stay on the server side since we have so many dependancies related to {if logged in). (Ultimately we’re trying to generate anonymous account for live chat / favoriting and this is our best path there.)
Thanks for any help!
I doubt you’d be able to do this with a PHP enabled template. You’ll need a module with action IDs setup so you can expose endpoints to POST data to.
In the past, I’ve gone through the member module’s code and replicated the entire login procedure from there. As I recall it’s about 200 lines, but can be cut down significantly, if you go through it carefully. That’s the best way to see how EE is actually creating users’ sessions.
I did find this blog post, which may help. But when I was working on a similar project, the best way I found to figure out what to do was to look at some existing modules that do the same thing and see how they do it.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.