<html><head><META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Persistant Storage</title><link href="modsecurity-reference.css" rel="stylesheet" type="text/css"><meta content="DocBook XSL Stylesheets V1.69.1" name="generator"><link rel="start" href="index.html" title="ModSecurity® Reference Manual"><link rel="up" href="index.html" title="ModSecurity® Reference Manual"><link rel="prev" href="ar01s10.html" title="Macro Expansion"><link rel="next" href="ar01s12.html" title="Miscellaneous Topics"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div style="background:#F5F5F5;width:100%;border-top:1px solid #DDDDDD;border-bottom:1px solid #DDDDDD"><table width="100%" cellspacing="0" cellpadding="0"><tr><td><a href="http://www.modsecurity.org"><img style="margin:4px" src="modsecurity.gif" width="120" height="36" alt="ModSecurity" border="0"></a></td><td align="right"><a href="http://www.breach.com"><img style="margin:6px" src="breach-logo-small.gif" height="36" width="100" border="0"></a></td></tr></table></div><div id="navheader"><table summary="Navigation header" width="100%"><tr><th align="center" colspan="3">Persistant Storage</th></tr><tr><td align="left" width="20%"><a accesskey="p" href="ar01s10.html">Prev</a> </td><td align="center" width="60%"> <a accesskey="h" href="index.html">Home</a></td><td align="right" width="20%"> <a accesskey="n" href="ar01s12.html">Next</a></td></tr></table><hr size="1"></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="N11EEA"></a>Persistant Storage</h2></div></div><div></div></div><p>At this time it is only possible to have three collections in which data is stored persistantly (i.e. data available to multiple requests). These are: <code class="literal">IP</code>, <code class="literal"> SESSION</code> and <code class="literal">USER</code>.</p><p>Every collection contains several built-in variables that are available and are read-only unless otherwise specified:</p><div class="orderedlist"><ol type="1"><li><p><code class="literal">CREATE_TIME</code> - date/time of the creation of the collection.</p></li><li><p><code class="literal">IS_NEW</code> - set to 1 if the collection is new (not yet persisted) otherwise set to 0.</p></li><li><p><code class="literal">KEY</code> - the value of the initcol variable (the client's IP address in the example).</p></li><li><p><code class="literal">LAST_UPDATE_TIME</code> - date/time of the last update to the collection.</p></li><li><p><code class="literal">TIMEOUT</code> - date/time in seconds when the collection will be updated on disk from memory (if no other updates occur). This variable may be set if you wish to specifiy an explicit expiration time (default is 3600 seconds).</p></li><li><p><code class="literal">UPDATE_COUNTER</code> - how many times the collection has been updated since creation.</p></li><li><p><code class="literal">UPDATE_RATE</code> - is the average rate updates per minute since creation.</p></li></ol></div><p>To create a collection to hold session variables (<code class="literal">SESSION</code>) use action <code class="literal">setsid</code>. To create a collection to hold user variables (<code class="literal">USER</code>) use action <code class="literal">setuid</code>. To create a collection to hold client address variables (<code class="literal">IP</code>) use action <code class="literal">initcol</code>.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>ModSecurity implements atomic updates of persistent variables only for integer variables (counters) at this time. Variables are read from storage whenever <code class="literal">initcol</code> is encountered in the rules and persisted at the end of request processing. Counters are adjusted by applying a delta generated by re-reading the persisted data just before being persisted. This keeps counter data consistent even if the counter was modified and persisted by another thread/process during the transaction.</p></div><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>ModSecurity uses a Berkley Database (SDBM) for persistant storage. This type of database is generally limited to storing a maximum of 1008 bytes per key. This may be a limitation if you are attempting to store a considerable amount of data in variables for a single key. Some of this limitation is planned to be reduced in a future version of ModSecurity.</p></div></div><div id="navfooter"><hr size="1"><table summary="Navigation footer" width="100%"><tr><td align="left" width="40%"><a accesskey="p" href="ar01s10.html">Prev</a> </td><td align="center" width="20%"> </td><td align="right" width="40%"> <a accesskey="n" href="ar01s12.html">Next</a></td></tr><tr><td valign="top" align="left" width="40%">Macro Expansion </td><td align="center" width="20%"><a accesskey="h" href="index.html">Home</a></td><td valign="top" align="right" width="40%"> Miscellaneous Topics</td></tr></table></div><div align="center" class="copyright">Copyright (C) 2004-2010 <a href="http://www.breach.com">Breach Security</a></div></body></html>