Create session for a user without loggin in


#1

Hello,

Anyone knows if I can create a session for a user without using a password?

I came across this:

// Create entry in stat table…
Stat::create(
Stat::TYPE_LOCAL_AUTH,
_user->id, array_merge( isset( _SESSION ) ? _SESSION : array(), _user->getAttributes()
)
);

So in theory, fetching the user object and running this code should create a session?

Thanks


#2

Assuming you are talking about logging in from PHP code running in the DSP context. If so, then have a look at the lib-php-common-platform library /src/Resources/User/Session.php:userLogin() and /src/Services/SystemManager.php:autoLoginAdmin(). I am not sure if you want the actual session info generated or just a logged user, either way this should give you some ideas.


#3

Thats the one thanks