---
name: "Data::Session::Driver::ODBC"
section: "3pm"
platform: "linux"
package: "libdata-session-perl"
version: "1.18-2"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Data::Session::Driver::ODBC"
---

# Data::Session::Driver::ODBC(3pm)

A persistent session manager

## NAME

Data::Session::Driver::ODBC - A persistent session manager

## Synopsis

See Data::Session for details.

## Description

Data::Session::Driver::ODBC allows Data::Session to store sessions via DBD::ODBC.

To use this module do both of these:

- o Specify a driver of type ODBC, as Data::Session -\> new(type =\> 'driver:ODBC ...')

  - o Specify a database handle as Data::Session -\> new(dbh =\> $dbh), or a data source as Data::Session -\> new(data\_source =\> $string)

  ## Case-sensitive Options

See "Case-sensitive Options" in Data::Session for important information.

## Method: new()

Creates a new object of type Data::Session::Driver::ODBC.

`"new()"` takes a hash of key/value pairs, some of which might mandatory. Further, some combinations might be mandatory.

The keys are listed here in alphabetical order.

They are lower-case because they are (also) method names, meaning they can be called to set or get the value at any time.

- o data\_col\_name =\> $string

  Specifes the name of the column in the sessions table which holds the session data.

  This key is normally passed in as Data::Session -\> new(data\_col\_name =\> `$string`).

  Default: 'a\_session'.

  This key is optional.

- o data\_source =\> $string

  Specifies the data source (as used by DBI -\> connect($data\_source, `$username`, `$password`, `$data_source_attr`) ) to obtain a database handle.

  This key is normally passed in as Data::Session -\> new(data\_source =\> `$string`).

  Default: ''.

  This key is optional, as long as a value is supplied for 'dbh'.

- o data\_source\_attr =\> $string

  Specifies the attributes (as used by DBI -\> connect($data\_source, `$username`, `$password`, `$data_source_attr`) ) to obtain a database handle.

  This key is normally passed in as Data::Session -\> new(data\_source\_attr =\> `$string`).

  Default: {AutoCommit =\> 1, PrintError =\> 0, RaiseError =\> 1}.

  This key is optional.

- o dbh =\> $dbh

  Specifies the database handle to use to access the sessions table.

  This key is normally passed in as Data::Session -\> new(dbh =\> `$dbh`).

  If not specified, this module will use the values of these keys to obtain a database handle:

  - o data\_source

    - o data\_source\_attr

    - o username

    - o password

    Default: ''.

  This key is optional.

- o host =\> $string

  Not used.

- o id\_col\_name =\> $string

  Specifes the name of the column in the sessions table which holds the session id.

  This key is normally passed in as Data::Session -\> new(id\_col\_name =\> `$string`).

  Default: 'id'.

  This key is optional.

- o password =\> $string

  Specifies the password (as used by DBI -\> connect($data\_source, `$username`, `$password`, `$data_source_attr`) ) to obtain a database handle.

  This key is normally passed in as Data::Session -\> new(password =\> `$string`).

  Default: ''.

  This key is optional.

- o port =\> $string

  Not used.

- o socket =\> $string

  Not used.

- o table\_name =\> $string

  Specifes the name of the sessions table.

  This key is normally passed in as Data::Session -\> new(table\_name =\> `$string`).

  Default: 'sessions'.

  This key is optional.

- o username =\> $string

  Specifies the username (as used by DBI -\> connect($data\_source, `$username`, `$password`, `$data_source_attr`) ) to obtain a database handle.

  This key is normally passed in as Data::Session -\> new(username =\> `$string`).

  Default: ''.

  This key is optional.

- o verbose =\> $integer

  Print to STDERR more or less information.

  Typical values are 0, 1 and 2.

  This key is normally passed in as Data::Session -\> new(verbose =\> `$integer`).

  This key is optional.

## Method: remove($id)

Deletes from storage the session identified by `$id`, or dies if it can't.

Returns 1.

## Method: retrieve($id)

Retrieve from storage the session identified by `$id`, or dies if it can't.

Returns the session.

This is a frozen session. This value must be thawed by calling the appropriate serialization driver's **thaw()** method.

Data::Session calls the right **thaw()** automatically.

## Method: store($id =\> $data)

Writes to storage the session identified by `$id`, together with its data `$data`, or dies if it can't.

Returns 1.

## Method: traverse()

Retrieves all ids from the sessions table, and for each id calls the supplied subroutine with the id as the only parameter.

`$dbh` -\> selectall\_arrayref is used, and the table is not locked.

Returns 1.

## Support

Log a bug on RT: \<https://rt.cpan.org/Public/Dist/Display.html?Name=Data-Session\>.

## Author

Data::Session was written by Ron Savage *\<ron@savage.net.au\>* in 2010.

Home page: \<http://savage.net.au/index.html\>.

## Copyright

Australian copyright (c) 2010, Ron Savage.

```
        All Programs of mine are 'OSI Certified Open Source Software';
        you can redistribute them and/or modify them under the terms of
        The Artistic License, a copy of which is available at:
        http://www.opensource.org/licenses/index.html
```
