User Login
Call the createNewSession
function: API Reference
SuperTokens\SuperTokens::createNewSession($response, $userId, $jwtPayload, $sessionData)
$jwtPayload
(type array
) should not contain any sensitive information.
$sessionData
(type array
) is stored in your database and can contain any information.
- This will attach all relevant cookies and header to the
$response
object.
Example
use SuperTokens\SuperTokens;
Route::post('/login', function () {
$response = new \Illuminate\Http\Response();
$userId = "User1";
$jwtPayload = ["name" => "spooky action at a distance"];
$sessionData = ["awesomeThings" => ["programming", "javascript", "supertokens"]];
SuperTokens::createNewSession($response, $userId, $jwtPayload, $sessionData);
return $response;
});