CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (Github)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C CakePHP 4.6 Strawberry API

  • Project:
    • CakePHP
      • CakePHP
      • Authentication
      • Authorization
      • Chronos
      • Elastic Search
      • Queue
  • Version:
    • 4.6
      • 5.2
      • 5.1
      • 5.0
      • 4.6
      • 4.5
      • 4.4
      • 4.3
      • 4.2
      • 4.1
      • 4.0
      • 3.10
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Namespaces

  • Global
  • Cake
    • Auth
    • Cache
    • Collection
    • Command
    • Console
    • Controller
    • Core
    • Database
    • Datasource
    • Error
    • Event
    • Filesystem
    • Form
    • Http
      • Client
      • Cookie
      • Exception
      • Middleware
      • Session
      • TestSuite
    • I18n
    • Log
    • Mailer
    • Network
    • ORM
    • Routing
    • Shell
    • TestSuite
    • Utility
    • Validation
    • View

Class DatabaseSession

DatabaseSession provides methods to be used with Session.

Namespace: Cake\Http\Session

Property Summary

  • $_table protected
    Cake\ORM\Table

    Reference to the table handling the session data

  • $_tableLocator protected
    Cake\ORM\Locator\LocatorInterface|null

    Table locator instance

  • $_timeout protected
    int

    Number of seconds to mark the session as expired

  • $defaultTable protected
    string|null

    This object's default table alias.

Method Summary

  • __construct() public

    Constructor. Looks at Session configuration information and sets up the session model.

  • close() public

    Method called on close of a database session.

  • destroy() public

    Method called on the destruction of a database session.

  • fetchTable() public

    Convenience method to get a table instance.

  • gc() public

    Helper function called on gc for database sessions.

  • getTableLocator() public

    Gets the table locator.

  • open() public

    Method called on open of a database session.

  • read() public

    Method used to read from a database session.

  • setTableLocator() public

    Sets the table locator.

  • setTimeout() public

    Set the timeout value for sessions.

  • write() public

    Helper function called on write for database sessions.

Method Detail

__construct() ¶ public

__construct(array<string, mixed> $config = [])

Constructor. Looks at Session configuration information and sets up the session model.

Parameters
array<string, mixed> $config optional

The configuration for this engine. It requires the 'model' key to be present corresponding to the Table to use for managing the sessions.

close() ¶ public

close(): bool

Method called on close of a database session.

Returns
bool

destroy() ¶ public

destroy(string $id): bool

Method called on the destruction of a database session.

Parameters
string $id

ID that uniquely identifies session in database.

Returns
bool

fetchTable() ¶ public

fetchTable(string|null $alias = null, array<string, mixed> $options = []): Cake\ORM\Table

Convenience method to get a table instance.

Parameters
string|null $alias optional

The alias name you want to get. Should be in CamelCase format. If null then the value of $defaultTable property is used.

array<string, mixed> $options optional

The options you want to build the table with. If a table has already been loaded the registry options will be ignored.

Returns
Cake\ORM\Table
Throws
Cake\Core\Exception\CakeException
If `$alias` argument and `$defaultTable` property both are `null`.
See Also
\Cake\ORM\TableLocator::get()

gc() ¶ public

gc(int $maxlifetime): int|false

Helper function called on gc for database sessions.

Parameters
int $maxlifetime

Sessions that have not updated for the last maxlifetime seconds will be removed.

Returns
int|false

getTableLocator() ¶ public

getTableLocator(): Cake\ORM\Locator\LocatorInterface

Gets the table locator.

Returns
Cake\ORM\Locator\LocatorInterface

open() ¶ public

open(string $path, string $name): bool

Method called on open of a database session.

Parameters
string $path

The path where to store/retrieve the session.

string $name

The session name.

Returns
bool

read() ¶ public

read(string $id): string|false

Method used to read from a database session.

Parameters
string $id

ID that uniquely identifies session in database.

Returns
string|false

setTableLocator() ¶ public

setTableLocator(Cake\ORM\Locator\LocatorInterface $tableLocator): $this

Sets the table locator.

Parameters
Cake\ORM\Locator\LocatorInterface $tableLocator

LocatorInterface instance.

Returns
$this

setTimeout() ¶ public

setTimeout(int $timeout): $this

Set the timeout value for sessions.

Primarily used in testing.

Parameters
int $timeout

The timeout duration.

Returns
$this

write() ¶ public

write(string $id, string $data): bool

Helper function called on write for database sessions.

Parameters
string $id

ID that uniquely identifies session in database.

string $data

The data to be saved.

Returns
bool

Property Detail

$_table ¶ protected

Reference to the table handling the session data

Type
Cake\ORM\Table

$_tableLocator ¶ protected

Table locator instance

Type
Cake\ORM\Locator\LocatorInterface|null

$_timeout ¶ protected

Number of seconds to mark the session as expired

Type
int

$defaultTable ¶ protected

This object's default table alias.

Type
string|null
OpenHub
Pingping
Linode
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (Github)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs