---
name: "Data::Session::Driver::File"
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::File"
---

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

A persistent session manager

## NAME

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

## Synopsis

See Data::Session for details.

## Description

Data::Session::Driver::File allows Data::Session to manipulate sessions via files.

To use this module do this:

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

  ## Case-sensitive Options

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

## Method: new()

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

`"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 debug =\> $Boolean

  Specifies that debugging should be turned on (1) or off (0) in Data::Session::File::Driver and Data::Session::ID::AutoIncrement.

  When debug is 1, $! is included in error messages, but because this reveals directory names, it is 0 by default.

  This key is optional.

  Default: 0.

- o directory =\> $string

  Specifies the path to the directory which will contain the session files.

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

  Default: File::Spec -\> tmpdir.

  This key is optional.

- o file\_name =\> $string\_containing\_%s

  Specifies the pattern to use for session file names. It must contain 1 '%s', which will be replaced by the session id before the pattern is used as a file name.

  This key is normally passed in as Data::Session -\> new(file\_name =\> `$string_containing_`%s).

  Default: 'cgisess\_%s'.

  This key is optional.

- o no\_flock =\> $boolean

  Specifies (no\_flock =\> 1) to not use **flock()** to obtain a lock on a session file before processing it, or (no\_flock =\> 0) to use **flock()**.

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

  Default: 0.

  This key is optional.

- o no\_follow =\> $value

  Influences the mode to use when calling **sysopen()** on session files.

  'Influences' means the value is bit-wise ored with O\_RDWR for reading and with O\_WRONLY for writing.

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

  Default: eval{O\_NOFOLLOW} \|\| 0.

  This key is optional.

- o umask =\> $octal\_value

  Specifies the mode to use when calling **sysopen()** on session files.

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

  Default: 0660.

  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`.

Returns 1 if it succeeds, and dies if it can't.

## Method: retrieve($id)

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

Returns the result of reading the session from the file identified by `$id`.

This result 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`.

Storage is a file identified by `$id`.

Returns 1 if it succeeds, and dies if it can't.

## Method: traverse($sub)

Retrieves all ids via their file names, and for each id calls the supplied subroutine with the id as the only parameter.

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
```
