New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using Redis for storing Sessions in Laravel 5.6 but facing browser issue #5275
Comments
may be php builtin function set your php.ini correctly:
hope this will help |
Thanks for your reply but still the issue is there even after making changes in php.ini file. Please suggest any other alternative. |
You are using session_start();
$session_id = $_SESSION['session_id'];
if (empty($session_id)) {
$_SESSION['session_id'] = str_random(40);
} |
It looks like you're assuming that if browser1 performs
Redis::set('session_id',$session_id); and browser2 performs
Redis::set('session_id',$session_id); that they have their own instances of
sessiond_id. However, redis is shared among all of the client
applications. If client one performs SET X 1 and client two performs SET X
2, and client one performs GET X, it will get the value 2. If you want
each browser to set and store its own unique session id, then you must use
unique keys. Very simplistically,
Redis::set('session_id_browser1',$session_id); and
Redis::set('session_id_browser2',$session_id); Obviously, this isn't
generic and doesn't scale - just intended to get the point across. You'll
need to identify some means for each browser to generic unique keys - not
just unique values. A common pattern is to define a key namespace for each
client instance where each key has some client specific prefix such as
'browser1:session_id' and 'browser2:session_id'.
…On Fri, Aug 24, 2018 at 9:19 AM Yang Tao ***@***.***> wrote:
You are using $_SESSION now right ?
session_start();$session_id = $_SESSION['session_id'];if (empty($session_id)) { $_SESSION['session_id'] = str_random(40);}
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_antirez_redis_issues_5275-23issuecomment-2D415772999&d=DwMCaQ&c=q3cDpHe1hF8lXU5EFjNM_A&r=N1Msa0ZexCqrdtWLgqlbMZlNrFKF4YmyP5otZCNJ7mmERCt9HPx5t646YC5_jvy8&m=sZT3-rTvKtTemB2MEjdEUClSQLEz5N3AtPiWUyMipx0&s=l-ycEVXYGncrlAOFygb4vfhoWwbUMy5EMt1EW5oAKU0&e=>,
or mute the thread
<https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AVxAa471tenSVdrQMb7ZO3W4-5Frzpkv1wks5uUAuLgaJpZM4WK3qi&d=DwMCaQ&c=q3cDpHe1hF8lXU5EFjNM_A&r=N1Msa0ZexCqrdtWLgqlbMZlNrFKF4YmyP5otZCNJ7mmERCt9HPx5t646YC5_jvy8&m=sZT3-rTvKtTemB2MEjdEUClSQLEz5N3AtPiWUyMipx0&s=LrRqFZtu3KGHMLYwuQgY0vTDCvWF_mX79ksF4KgQOMc&e=>
.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am using Redis in Laravel 5.6 for storing Sessions but its updating in all browsers like when I add session_id variable and sets its value in Redis then it not only assigned and displays in one browser but also to other.
Like if I assign some value to Redis variable in Chrome browser then it also shows in Firefox browser as well.
But I want to maintain separate Redis Session in separate browser like it happens with standard PHP Sessions.
Please check my below code where I assign the value to Redis session_id variable if its empty.
$session_id = Redis::get('session_id');
if(empty($session_id)){
$session_id = str_random(40);
Redis::set('session_id',$session_id);
}
Please help me to modify this code to make it browser specific.
How do I assign the value to Redis Session variable that can be read by one browser only, not by other.
Hope someone can help me! Thanks.
The text was updated successfully, but these errors were encountered: