PHP中的AWS DynamoDb会话处理程序:session_id()在EC2实例之间返回不同的值 [英] AWS DynamoDb Session Handler in PHP: session_id() returns different values between EC2 instances

查看:151
本文介绍了PHP中的AWS DynamoDb会话处理程序:session_id()在EC2实例之间返回不同的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个使用Apache2和PHP的EC2实例。

I have 2 EC2 instances with Apache2 and PHP.

两个实例都包含AWS DynamoDB的会话处理程序,并且这些值都写在数据库中。但是当我尝试获取session_id()时,返回两个不同的值...

Both instances contains the session handler of AWS DynamoDB and the values were written in database. But when I try to get session_id(), returns two differents values...

怎么了?

推荐答案

我理解了这个问题……

我试图在本地计算机和EC2实例上进行测试我在下面两个正常运行的EC2实例中放置了代码。

I was trying to do tests on my local machine and on an EC2 instance, when I put the code below in 2 EC2 instances functioned normally.

use Aws\DynamoDb\DynamoDbClient;
use Aws\DynamoDb\Session;

try {
    $dynamoDb = DynamoDbClient::factory(array(
        'key'    => 'AWS_KEY',
        'secret' => 'AWS_SECRET',
        'region' => 'AWS_REGION'
    ));

    $sessionHandler = $dynamoDb->registerSessionHandler(array(
        'table_name'               => 'session',
        'hash_key'                 => 'id',
        'session_lifetime'         => 3600,
        'consistent_read'          => true,
        'locking_strategy'         => null,
        'automatic_gc'             => 0,
        'gc_batch_size'            => 50,
        'max_lock_wait_time'       => 15,
        'min_lock_retry_microtime' => 5000,
        'max_lock_retry_microtime' => 50000,
    ));
} catch (Exception $e) {
    exit($e->getMessage());
}

这篇关于PHP中的AWS DynamoDb会话处理程序:session_id()在EC2实例之间返回不同的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆