Redis®*: Handle PHP sessions with Redis

This documentation is part of the Getting started guide. View the full guide here: Quick guide to getting started with Redis.

👋 Welcome to the Stackhero documentation!

Stackhero offers a ready-to-use Redis cloud solution that provides a host of benefits, including:

  • Redis Commander web UI included.
  • Unlimited message size and transfers.
  • Effortless updates with just a click.
  • Optimal performance and robust security powered by a private and dedicated VM.

Save time and simplify your life: it only takes 5 minutes to try Stackhero's Redis cloud hosting solution!

If you would like to store PHP sessions on Stackhero for Redis, you can use the following example:

<?php

// Parse Redis URL
$redis_url = parse_url("rediss://default:<yourPassword>@<XXXXXX>.stackhero-network.com:<PORT_TLS>")

// Configure session handler
ini_set("session.save_handler", "redis")
ini_set("session.save_path", "tls://{$redis_url["host"]}:{$redis_url["port"]}?auth={$redis_url["pass"]}&timeout=5")

// Start the session
session_start()

?>