# The UserAgent Storage Interface

## Overview

Because discovering and identifying mobile device capabilities can involve a number of resources, it's often useful to identify the capabilities on the first visit, and cache it for subsequent visits.

The Zend_Http_UserAgent_Storage interface provides a simple definition for defining storage adapters capable of persisting definitions. By default, a Session storage adapter is used, which persists the data in a Zend_Session_Namespace instance.

## Quick Start

The interface provides simply the ability to read from, write to, test for, and clear data in the persistence backend.

    interface Zend_Http_UserAgent_Storage
    {
        public function isEmpty();
        public function read();
        public function write($contents);
        public function clear();
    }

By default, the Zend_Http_UserAgent_Storage_Session adapter is utilized. That adapter writes to a unique Zend_Session_Namespace for the given user.

## Configuration Options

See the individual storage adapters for configuration options. Most adapters will accept an array or object as an argument to the constructor, and the UserAgent class allows passing an array of options.

## Available Methods

isEmpty

  Test whether ornot the storage adapter has an entry. Returns true if the storage is currently unpopulated.

read

  Reads data from storage; the data will be serialized PHP.

write $contents

  Write a serialized string to the storage engine.

clear

  Should empty the storage; calling isEmpty() following a clear() operation should return `true`.