Upgrade the Session module

Edit on GitHub

This migration guide is a part of the Silex migration effort.

To upgrade the module, do the following:

  1. Install modules using Composer:
composer require spryker/session spryker/event-dispatcher
  1. Remove old service providers, if you have them in the project:
\Silex\Provider\SessionServiceProvider
\Spryker\Yves\Session\Plugin\ServiceProvider\SessionServiceProvider
\Spryker\Zed\Session\Communication\Plugin\ServiceProvider\SessionServiceProvider
\Spryker\Zed\Application\Communication\Plugin\ServiceProvider\SaveSessionServiceProvider
  1. Enable new plugins:

Zed integration (when usable in ZED)

<?php

namespace Pyz\Zed\Application;

use Spryker\Zed\Application\ApplicationDependencyProvider as SprykerApplicationDependencyProvider;
use Spryker\Zed\Session\Communication\Plugin\Application\SessionApplicationPlugin;

class ApplicationDependencyProvider extends SprykerApplicationDependencyProvider
{
	...
	/**
     * @return \Spryker\Shared\ApplicationExtension\Dependency\Plugin\ApplicationPluginInterface[]
     */
    protected function getApplicationPlugins(): array
	{
		return [
			...
			new SessionApplicationPlugin(),
   			...
		];
	}
	...
}

Zed integration (when usable in ZED)

<?php

namespace Pyz\Zed\EventDispatcher;

use Spryker\Zed\EventDispatcher\EventDispatcherDependencyProvider as SprykerEventDispatcherDependencyProvider;
use Spryker\Zed\Session\Communication\Plugin\EventDispatcher\SaveSessionEventDispatcherPlugin;
use Spryker\Zed\Session\Communication\Plugin\EventDispatcher\SessionEventDispatcherPlugin;

class EventDispatcherDependencyProvider extends SprykerEventDispatcherDependencyProvider
{
    /**
     * @return \Spryker\Shared\EventDispatcherExtension\Dependency\Plugin\EventDispatcherPluginInterface[]
     */
    protected function getEventDispatcherPlugins(): array
    {
        return [
            ...
            new SessionEventDispatcherPlugin(),
            new SaveSessionEventDispatcherPlugin(),
            ...
        ];
    }
}

Yves integration (when usable in Yves)

<?php

namespace Pyz\Yves\ShopApplication;

use Spryker\Yves\Session\Plugin\Application\SessionApplicationPlugin;
use SprykerShop\Yves\ShopApplication\ShopApplicationDependencyProvider as SprykerShopApplicationDependencyProvider;

class ShopApplicationDependencyProvider extends SprykerShopApplicationDependencyProvider
{
    /**
     * @return \Spryker\Shared\ApplicationExtension\Dependency\Plugin\ApplicationPluginInterface[]
     */
    protected function getApplicationPlugins(): array
    {
        return [
            ...
            new SessionApplicationPlugin(),
            ...
        ];
    }
}

Yves integration (when usable in Yves)

<?php

namespace Pyz\Yves\EventDispatcher;

use Spryker\Yves\EventDispatcher\EventDispatcherDependencyProvider as SprykerEventDispatcherDependencyProvider;
use Spryker\Yves\Session\Plugin\EventDispatcher\SessionEventDispatcherPlugin;

class EventDispatcherDependencyProvider extends SprykerEventDispatcherDependencyProvider
{
    /**
     * @return \Spryker\Shared\EventDispatcherExtension\Dependency\Plugin\EventDispatcherPluginInterface[]
     */
    protected function getEventDispatcherPlugins(): array
    {
        return [
            ...
            new SessionEventDispatcherPlugin(),
            ...
        ];
    }
}

Glue integration (required as a mock)

<?php

namespace Pyz\Glue\GlueApplication;

use Spryker\Glue\GlueApplication\GlueApplicationDependencyProvider as SprykerGlueApplicationDependencyProvider;
use Spryker\Glue\Session\Plugin\Application\SessionApplicationPlugin;

class GlueApplicationDependencyProvider extends SprykerGlueApplicationDependencyProvider
{
    /**
     * @return \Spryker\Shared\ApplicationExtension\Dependency\Plugin\ApplicationPluginInterface[]
     */
    protected function getApplicationPlugins(): array
    {
        return [
            ...
            new SessionApplicationPlugin(),
            ...
        ];
    }
}

Upgrading from version 3.* to version 4.*

The previous version made use of the deprecated spryker/new-relic and the spryker/new-relic-api modules. To be able to use this version you need to install the spryker/monitoring module if you haven’t done already by running:

composer require spryker/monitoring

All session handler classes provided by this module are now using the monitoring module instead of the new-relic module. Additionally we moved some constants from the SessionConstants file to the SessionConfig file. You need to update your config_* files and use as values for the session configuration the ones which come from the SessionConfig file now.

Example:

You need to change all: $config[SessionConstants::CONFIG_KEY] = SessionConstants::CONFIG_VALUE; to: $config[SessionConstants::CONFIG_KEY] = SessionConfig::CONFIG_VALUE;