AWS SDK for PHP 3.x
  • Namespace
  • Class
Did this page help you? SUBMIT FEEDBACK!

Namespaces

  • Aws
    • AccessAnalyzer
      • Exception
    • Acm
      • Exception
    • ACMPCA
      • Exception
    • AlexaForBusiness
      • Exception
    • Amplify
      • Exception
    • AmplifyBackend
      • Exception
    • Api
      • ErrorParser
      • Parser
        • Exception
      • Serializer
    • ApiGateway
      • Exception
    • ApiGatewayManagementApi
      • Exception
    • ApiGatewayV2
      • Exception
    • AppConfig
      • Exception
    • Appflow
      • Exception
    • AppIntegrationsService
      • Exception
    • ApplicationAutoScaling
      • Exception
    • ApplicationDiscoveryService
      • Exception
    • ApplicationInsights
      • Exception
    • AppMesh
      • Exception
    • AppRegistry
      • Exception
    • Appstream
      • Exception
    • AppSync
      • Exception
    • Arn
      • Exception
    • Athena
      • Exception
    • AuditManager
      • Exception
    • AugmentedAIRuntime
      • Exception
    • AutoScaling
      • Exception
    • AutoScalingPlans
      • Exception
    • Backup
      • Exception
    • Batch
      • Exception
    • Braket
      • Exception
    • Budgets
      • Exception
    • Chime
      • Exception
    • ClientSideMonitoring
      • Exception
    • Cloud9
      • Exception
    • CloudDirectory
      • Exception
    • CloudFormation
      • Exception
    • CloudFront
      • Exception
    • CloudHsm
      • Exception
    • CloudHSMV2
      • Exception
    • CloudSearch
      • Exception
    • CloudSearchDomain
      • Exception
    • CloudTrail
      • Exception
    • CloudWatch
      • Exception
    • CloudWatchEvents
      • Exception
    • CloudWatchLogs
      • Exception
    • CodeArtifact
      • Exception
    • CodeBuild
      • Exception
    • CodeCommit
      • Exception
    • CodeDeploy
      • Exception
    • CodeGuruProfiler
      • Exception
    • CodeGuruReviewer
      • Exception
    • CodePipeline
      • Exception
    • CodeStar
      • Exception
    • CodeStarconnections
      • Exception
    • CodeStarNotifications
      • Exception
    • CognitoIdentity
      • Exception
    • CognitoIdentityProvider
      • Exception
    • CognitoSync
      • Exception
    • Comprehend
      • Exception
    • ComprehendMedical
      • Exception
    • ComputeOptimizer
      • Exception
    • ConfigService
      • Exception
    • Connect
      • Exception
    • ConnectContactLens
      • Exception
    • ConnectParticipant
      • Exception
    • CostandUsageReportService
      • Exception
    • CostExplorer
      • Exception
    • Credentials
    • Crypto
      • Cipher
      • Polyfill
    • CustomerProfiles
      • Exception
    • DatabaseMigrationService
      • Exception
    • DataExchange
      • Exception
    • DataPipeline
      • Exception
    • DataSync
      • Exception
    • DAX
      • Exception
    • Detective
      • Exception
    • DeviceFarm
      • Exception
    • DevOpsGuru
      • Exception
    • DirectConnect
      • Exception
    • DirectoryService
      • Exception
    • DLM
      • Exception
    • DocDB
      • Exception
    • DynamoDb
      • Exception
    • DynamoDbStreams
      • Exception
    • EBS
      • Exception
    • Ec2
      • Exception
    • EC2InstanceConnect
      • Exception
    • Ecr
      • Exception
    • ECRPublic
      • Exception
    • Ecs
      • Exception
    • Efs
      • Exception
    • EKS
      • Exception
    • ElastiCache
      • Exception
    • ElasticBeanstalk
      • Exception
    • ElasticInference
      • Exception
    • ElasticLoadBalancing
      • Exception
    • ElasticLoadBalancingV2
      • Exception
    • ElasticsearchService
      • Exception
    • ElasticTranscoder
      • Exception
    • Emr
      • Exception
    • EMRContainers
      • Exception
    • Endpoint
    • EndpointDiscovery
      • Exception
    • EventBridge
      • Exception
    • Exception
    • Firehose
      • Exception
    • FIS
      • Exception
    • FMS
      • Exception
    • ForecastQueryService
      • Exception
    • ForecastService
      • Exception
    • FraudDetector
      • Exception
    • FSx
      • Exception
    • GameLift
      • Exception
    • Glacier
      • Exception
    • GlobalAccelerator
      • Exception
    • Glue
      • Exception
    • GlueDataBrew
      • Exception
    • Greengrass
      • Exception
    • GreengrassV2
      • Exception
    • GroundStation
      • Exception
    • GuardDuty
      • Exception
    • Handler
      • GuzzleV5
      • GuzzleV6
    • Health
      • Exception
    • HealthLake
      • Exception
    • Honeycode
      • Exception
    • Iam
      • Exception
    • IdentityStore
      • Exception
    • imagebuilder
      • Exception
    • ImportExport
      • Exception
    • Inspector
      • Exception
    • Iot
      • Exception
    • IoT1ClickDevicesService
      • Exception
    • IoT1ClickProjects
      • Exception
    • IoTAnalytics
      • Exception
    • IotDataPlane
      • Exception
    • IoTDeviceAdvisor
      • Exception
    • IoTEvents
      • Exception
    • IoTEventsData
      • Exception
    • IoTFleetHub
      • Exception
    • IoTJobsDataPlane
      • Exception
    • IoTSecureTunneling
      • Exception
    • IoTSiteWise
      • Exception
    • IoTThingsGraph
      • Exception
    • IoTWireless
      • Exception
    • IVS
      • Exception
    • Kafka
      • Exception
    • kendra
      • Exception
    • Kinesis
      • Exception
    • KinesisAnalytics
      • Exception
    • KinesisAnalyticsV2
      • Exception
    • KinesisVideo
      • Exception
    • KinesisVideoArchivedMedia
      • Exception
    • KinesisVideoMedia
      • Exception
    • KinesisVideoSignalingChannels
      • Exception
    • Kms
      • Exception
    • LakeFormation
      • Exception
    • Lambda
      • Exception
    • LexModelBuildingService
      • Exception
    • LexModelsV2
      • Exception
    • LexRuntimeService
      • Exception
    • LexRuntimeV2
      • Exception
    • LicenseManager
      • Exception
    • Lightsail
      • Exception
    • LocationService
      • Exception
    • LookoutEquipment
      • Exception
    • LookoutforVision
      • Exception
    • LookoutMetrics
      • Exception
    • MachineLearning
      • Exception
    • Macie
      • Exception
    • Macie2
      • Exception
    • ManagedBlockchain
      • Exception
    • MarketplaceCatalog
      • Exception
    • MarketplaceCommerceAnalytics
      • Exception
    • MarketplaceEntitlementService
      • Exception
    • MarketplaceMetering
      • Exception
    • MediaConnect
      • Exception
    • MediaConvert
      • Exception
    • MediaLive
      • Exception
    • MediaPackage
      • Exception
    • MediaPackageVod
      • Exception
    • MediaStore
      • Exception
    • MediaStoreData
      • Exception
    • MediaTailor
      • Exception
    • mgn
      • Exception
    • MigrationHub
      • Exception
    • MigrationHubConfig
      • Exception
    • Mobile
      • Exception
    • MQ
      • Exception
    • MTurk
      • Exception
    • Multipart
    • MWAA
      • Exception
    • Neptune
      • Exception
    • NetworkFirewall
      • Exception
    • NetworkManager
      • Exception
    • OpsWorks
      • Exception
    • OpsWorksCM
      • Exception
    • Organizations
      • Exception
    • Outposts
      • Exception
    • Personalize
      • Exception
    • PersonalizeEvents
      • Exception
    • PersonalizeRuntime
      • Exception
    • PI
      • Exception
    • Pinpoint
      • Exception
    • PinpointEmail
      • Exception
    • PinpointSMSVoice
      • Exception
    • Polly
      • Exception
    • Pricing
      • Exception
    • PrometheusService
      • Exception
    • QLDB
      • Exception
    • QLDBSession
      • Exception
    • QuickSight
      • Exception
    • RAM
      • Exception
    • Rds
      • Exception
    • RDSDataService
      • Exception
    • Redshift
      • Exception
    • RedshiftDataAPIService
      • Exception
    • Rekognition
      • Exception
    • ResourceGroups
      • Exception
    • ResourceGroupsTaggingAPI
      • Exception
    • Retry
      • Exception
    • RoboMaker
      • Exception
    • Route53
      • Exception
    • Route53Domains
      • Exception
    • Route53Resolver
      • Exception
    • S3
      • Crypto
      • Exception
      • RegionalEndpoint
        • Exception
      • UseArnRegion
        • Exception
    • S3Control
      • Exception
    • S3Outposts
      • Exception
    • SageMaker
      • Exception
    • SagemakerEdgeManager
      • Exception
    • SageMakerFeatureStoreRuntime
      • Exception
    • SageMakerRuntime
      • Exception
    • SavingsPlans
      • Exception
    • Schemas
      • Exception
    • SecretsManager
      • Exception
    • SecurityHub
      • Exception
    • ServerlessApplicationRepository
      • Exception
    • ServiceCatalog
      • Exception
    • ServiceDiscovery
      • Exception
    • ServiceQuotas
      • Exception
    • Ses
      • Exception
    • SesV2
      • Exception
    • Sfn
      • Exception
    • Shield
      • Exception
    • Signature
    • signer
      • Exception
    • Sms
      • Exception
    • SnowBall
      • Exception
    • Sns
      • Exception
    • Sqs
      • Exception
    • Ssm
      • Exception
    • SSO
      • Exception
    • SSOAdmin
      • Exception
    • SSOOIDC
      • Exception
    • StorageGateway
      • Exception
    • Sts
      • Exception
      • RegionalEndpoints
        • Exception
    • Support
      • Exception
    • Swf
      • Exception
    • Synthetics
      • Exception
    • Textract
      • Exception
    • TimestreamQuery
      • Exception
    • TimestreamWrite
      • Exception
    • TranscribeService
      • Exception
    • Transfer
      • Exception
    • Translate
      • Exception
    • Waf
      • Exception
    • WafRegional
      • Exception
    • WAFV2
      • Exception
    • WellArchitected
      • Exception
    • WorkDocs
      • Exception
    • WorkLink
      • Exception
    • WorkMail
      • Exception
    • WorkMailMessageFlow
      • Exception
    • WorkSpaces
      • Exception
    • XRay
      • Exception
  • GuzzleHttp
    • Promise
    • Psr7
  • Psr
    • Http
      • Message

Classes

  • BinaryValue
  • DynamoDbClient
  • LockingSessionConnection
  • Marshaler
  • NumberValue
  • SessionHandler
  • SetValue
  • StandardSessionConnection
  • WriteRequestBatch

Interfaces

  • SessionConnectionInterface

Traits

  • SessionConnectionConfigTrait
AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.

Class SessionHandler

Aws\DynamoDb\SessionHandler implements SessionHandlerInterface
Namespace: Aws\DynamoDb
Located at DynamoDb/SessionHandler.php

Provides an interface for using Amazon DynamoDB as a session store by hooking into PHP's session handler hooks. Once registered, You may use the native $_SESSION superglobal and session functions, and the sessions will be stored automatically in DynamoDB. DynamoDB is a great session storage solution due to its speed, scalability, and fault tolerance.

For maximum performance, we recommend that you keep the size of your sessions small. Locking is disabled by default, since it can drive up latencies and costs under high traffic. Only turn it on if you need it.

By far, the most expensive operation is garbage collection. Therefore, we encourage you to carefully consider your session garbage collection strategy. Note: the DynamoDB Session Handler does not allow garbage collection to be triggered randomly. You must run garbage collection manually or through other automated means using a cron job or similar scheduling technique.

Methods Summary

  • static fromClient ( Aws\DynamoDb\DynamoDbClient $client, array $config = [] )

    Creates a new DynamoDB Session Handler.

  • __construct ( Aws\DynamoDb\SessionConnectionInterface $connection )
  • register ( )

    Register the DynamoDB session handler.

  • open ( string $savePath, string $sessionName )

    Open a session for writing. Triggered by session_start().

  • close ( )

    Close a session from writing.

  • read ( string $id )

    Read a session stored in DynamoDB.

  • write ( string $id, string $data )

    Write a session to DynamoDB.

  • destroy ( string $id )

    Delete a session stored in DynamoDB.

  • gc ( int $maxLifetime )

    Satisfies the session handler interface, but does nothing. To do garbage collection, you must manually call the garbageCollect() method.

  • garbageCollect ( )

    Triggers garbage collection on expired sessions.

Methods Details

static Aws\DynamoDb\SessionHandler fromClient ( Aws\DynamoDb\DynamoDbClient $client, array $config = [] )

Creates a new DynamoDB Session Handler.

The configuration array accepts the following array keys and values: - table_name: Name of table to store the sessions. - hash_key: Name of hash key in table. Default: "id". - data_attribute: Name of the data attribute in table. Default: "data". - session_lifetime: Lifetime of inactive sessions expiration. - session_lifetime_attribute: Name of the session life time attribute in table. Default: "expires". - consistent_read: Whether or not to use consistent reads. - batch_config: Batch options used for garbage collection. - locking: Whether or not to use session locking. - max_lock_wait_time: Max time (s) to wait for lock acquisition. - min_lock_retry_microtime: Min time (µs) to wait between lock attempts. - max_lock_retry_microtime: Max time (µs) to wait between lock attempts.

You can find the full list of parameters and defaults within the trait Aws\DynamoDb\SessionConnectionConfigTrait

Parameters

Aws\DynamoDb\DynamoDbClient $client Client for doing DynamoDB operations
array $config = [] Configuration for the Session Handler

Returns

Aws\DynamoDb\SessionHandler

__construct ( Aws\DynamoDb\SessionConnectionInterface $connection )

Parameters

Aws\DynamoDb\SessionConnectionInterface $connection

boolean register ( )

Register the DynamoDB session handler.

Returns

boolean
Whether or not the handler was registered.

Codecoverageignore

boolean open ( string $savePath, string $sessionName )

Open a session for writing. Triggered by session_start().

Parameters

string $savePath Session save path.
string $sessionName Session name.

Returns

boolean
Whether or not the operation succeeded.

Implementation of

SessionHandlerInterface::open()

boolean close ( )

Close a session from writing.

Returns

boolean
Success

Implementation of

SessionHandlerInterface::close()

string read ( string $id )

Read a session stored in DynamoDB.

Parameters

string $id Session ID.

Returns

string
Session data.

Implementation of

SessionHandlerInterface::read()

boolean write ( string $id, string $data )

Write a session to DynamoDB.

Parameters

string $id Session ID.
string $data Serialized session data to write.

Returns

boolean
Whether or not the operation succeeded.

Implementation of

SessionHandlerInterface::write()

boolean destroy ( string $id )

Delete a session stored in DynamoDB.

Parameters

string $id Session ID.

Returns

boolean
Whether or not the operation succeeded.

Implementation of

SessionHandlerInterface::destroy()

boolean gc ( integer $maxLifetime )

Satisfies the session handler interface, but does nothing. To do garbage collection, you must manually call the garbageCollect() method.

Parameters

integer $maxLifetime Ignored.

Returns

boolean
Whether or not the operation succeeded.

Codecoverageignore

Implementation of

SessionHandlerInterface::gc()

garbageCollect ( )

Triggers garbage collection on expired sessions.

Codecoverageignore

AWS SDK for PHP 3.x API documentation generated by ApiGen