AWS Code Sample


SessionStart.php shows how to register a DynamoDB Session Handler and start a session.

<?php /** * Copyright 2010-2019, Inc. or its affiliates. All Rights Reserved. * * This file is licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. A copy of * the License is located at * * * * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * * ABOUT THIS PHP SAMPLE => This sample is part of the SDK for PHP Developer Guide topic at * * * */ require 'vendor/autoload.php'; use Aws\DynamoDb\SessionHandler; $sessionHandler = SessionHandler::fromClient($dynamoDb, [ 'table_name' => 'sessions' ]); $sessionHandler->register(); /** * SessionStart.php shows how to register a DynamoDB Session Handler. * * This code expects that you have AWS credentials set up per: * * * To use the DynamoDB SessionHhandler, your configured credentials must have permission to use the DynamoDB table. */ // Start the session session_start(); // Alter the session data $_SESSION[''] = 'jeremy'; $_SESSION['user.role'] = 'admin'; // Close the session (optional, but recommended) session_write_close();

Sample Details

Service: dynamodb

Last tested:

Author: AWS

Type: snippet

On this page: