I need to share information about the user who is signed in so that the currently signed in user can buy something via Blesta and he can also do some actions in my project. A user should sign in only once to be signed in my project and in Blesta at the same time.
Difficulties:
1) First problem is that Blesta and my project both uses SESSIONs.
Resolution:
I disabled in Blesta/Components/session/session.php (see the change below) some code that setup sessions to use database (it means that file storage is used for sessions now)
I set session.cookie-domain to ".example.com" so that the session cookie is shared among ALL subdomains of example.com (i.e. www.example.com and shop.example.com) and therefore I can work with the same $_SESSION array in Blesta and in my project.
2) Sign a user in Blesta and my project at the same time in MyProject/User/Login.php
Resolution:
I changed authentication in my project to use Blesta API to verify credentials (please see MyProject/User/Login.php source code below) where I set two SESSION variables:
$_SESSION['blesta_id'] = $user->id; and
$_SESSION['blesta_client_id'] = $client->id;
(Is it OK? Or should I set more variables in $_SESSION array?)
Question
MartyIX
Hello,
I'm trying to integrate Blesta to my project and I would like to know if I'm doing it correctly.
Setup:
Problem:
I need to share information about the user who is signed in so that the currently signed in user can buy something via Blesta and he can also do some actions in my project. A user should sign in only once to be signed in my project and in Blesta at the same time.
Difficulties:
1) First problem is that Blesta and my project both uses SESSIONs.
Resolution:
2) Sign a user in Blesta and my project at the same time in MyProject/User/Login.php
Resolution:
$_SESSION['blesta_id'] = $user->id; and
$_SESSION['blesta_client_id'] = $client->id;
(Is it OK? Or should I set more variables in $_SESSION array?)
Question
Is this correct way how to share login information between a custom made project and Blesta?
Source codes:
MyProject/User/Login.php (not Blesta!)
Blesta/Components/session/session.php
5 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.