Andrey Andreev | c576995 | 2019-01-16 17:49:35 +0200 | [diff] [blame^] | 1 | |
| 2 | |
| 3 | <!DOCTYPE html> |
| 4 | <!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> |
| 5 | <!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> |
| 6 | <head> |
| 7 | <meta charset="utf-8"> |
| 8 | <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| 9 | |
| 10 | <title>Session Library — CodeIgniter 3.1.10 documentation</title> |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | <link rel="shortcut icon" href="../_static/ci-icon.ico"/> |
| 16 | |
| 17 | |
| 18 | |
| 19 | <link href='https://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic|Roboto+Slab:400,700|Inconsolata:400,700&subset=latin,cyrillic' rel='stylesheet' type='text/css'> |
| 20 | |
| 21 | |
| 22 | |
| 23 | |
| 24 | |
| 25 | |
| 26 | |
| 27 | |
| 28 | |
| 29 | <link rel="stylesheet" href="../_static/css/citheme.css" type="text/css" /> |
| 30 | |
| 31 | |
| 32 | |
| 33 | <link rel="index" title="Index" |
| 34 | href="../genindex.html"/> |
| 35 | <link rel="search" title="Search" href="../search.html"/> |
| 36 | <link rel="top" title="CodeIgniter 3.1.10 documentation" href="../index.html"/> |
| 37 | <link rel="up" title="Libraries" href="index.html"/> |
| 38 | <link rel="next" title="HTML Table Class" href="table.html"/> |
| 39 | <link rel="prev" title="Security Class" href="security.html"/> |
| 40 | |
| 41 | |
| 42 | <script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js"></script> |
| 43 | |
| 44 | </head> |
| 45 | |
| 46 | <body class="wy-body-for-nav" role="document"> |
| 47 | |
| 48 | <div id="nav"> |
| 49 | <div id="nav_inner"> |
| 50 | |
| 51 | |
| 52 | |
| 53 | <div id="pulldown-menu" class="ciNav"> |
| 54 | <ul> |
| 55 | <li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> |
| 56 | </ul> |
| 57 | <ul> |
| 58 | <li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> |
| 59 | <li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> |
| 60 | <li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> |
| 61 | <li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> |
| 62 | <li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> |
| 63 | </ul> |
| 64 | </li> |
| 65 | </ul> |
| 66 | <ul> |
| 67 | <li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> |
| 68 | <li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> |
| 69 | <li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> |
| 70 | <li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> |
| 71 | <li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> |
| 72 | <li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> |
| 73 | <li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> |
| 74 | </ul> |
| 75 | </li> |
| 76 | </ul> |
| 77 | <ul> |
| 78 | <li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> |
| 79 | <li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> |
| 80 | <li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> |
| 81 | <li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> |
| 82 | <li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> |
| 83 | </ul> |
| 84 | </li> |
| 85 | </ul> |
| 86 | <ul> |
| 87 | <li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> |
| 88 | <li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> |
| 89 | <li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> |
| 90 | </ul> |
| 91 | </li> |
| 92 | </ul> |
| 93 | <ul> |
| 94 | <li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> |
| 95 | <li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> |
| 96 | <li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> |
| 97 | <li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> |
| 98 | <li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> |
| 99 | <li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> |
| 100 | <li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> |
| 101 | <li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> |
| 102 | <li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> |
| 103 | <li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> |
| 104 | <li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> |
| 105 | <li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> |
| 106 | <li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> |
| 107 | <li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> |
| 108 | <li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> |
| 109 | <li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> |
| 110 | <li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> |
| 111 | <li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> |
| 112 | <li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> |
| 113 | <li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> |
| 114 | <li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> |
| 115 | <li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> |
| 116 | <li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> |
| 117 | <li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> |
| 118 | <li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> |
| 119 | <li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> |
| 120 | <li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> |
| 121 | </ul> |
| 122 | </li> |
| 123 | </ul> |
| 124 | <ul class="current"> |
| 125 | <li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current"> |
| 126 | <li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> |
| 127 | <li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li> |
| 128 | <li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> |
| 129 | <li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> |
| 130 | <li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li> |
| 131 | <li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li> |
| 132 | <li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> |
| 133 | <li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li> |
| 134 | <li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> |
| 135 | <li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li> |
| 136 | <li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li> |
| 137 | <li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li> |
| 138 | <li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li> |
| 139 | <li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li> |
| 140 | <li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li> |
| 141 | <li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li> |
| 142 | <li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li> |
| 143 | <li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li> |
| 144 | <li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li> |
| 145 | <li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li> |
| 146 | <li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li> |
| 147 | <li class="toctree-l2 current"><a class="current reference internal" href="#">Session Library</a></li> |
| 148 | <li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li> |
| 149 | <li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li> |
| 150 | <li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li> |
| 151 | <li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> |
| 152 | <li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li> |
| 153 | <li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> |
| 154 | <li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> |
| 155 | <li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> |
| 156 | </ul> |
| 157 | </li> |
| 158 | </ul> |
| 159 | <ul> |
| 160 | <li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> |
| 161 | <li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> |
| 162 | <li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> |
| 163 | <li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> |
| 164 | <li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> |
| 165 | <li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> |
| 166 | <li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> |
| 167 | <li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> |
| 168 | <li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> |
| 169 | <li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> |
| 170 | <li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> |
| 171 | <li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> |
| 172 | <li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> |
| 173 | <li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> |
| 174 | <li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> |
| 175 | </ul> |
| 176 | </li> |
| 177 | </ul> |
| 178 | <ul> |
| 179 | <li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> |
| 180 | <li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> |
| 181 | <li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> |
| 182 | <li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> |
| 183 | <li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> |
| 184 | <li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> |
| 185 | <li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> |
| 186 | <li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> |
| 187 | <li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> |
| 188 | <li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> |
| 189 | <li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> |
| 190 | <li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> |
| 191 | <li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> |
| 192 | <li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> |
| 193 | <li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> |
| 194 | <li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> |
| 195 | <li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> |
| 196 | <li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> |
| 197 | <li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> |
| 198 | <li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> |
| 199 | <li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> |
| 200 | <li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> |
| 201 | </ul> |
| 202 | </li> |
| 203 | </ul> |
| 204 | |
| 205 | </div> |
| 206 | |
| 207 | |
| 208 | </div> |
| 209 | </div> |
| 210 | <div id="nav2"> |
| 211 | <a href="#" id="openToc"> |
| 212 | <img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAgAAZABkAAD/7AARRHVja3kAAQAEAAAARgAA/+4ADkFkb2JlAGTAAAAAAf/bAIQABAMDAwMDBAMDBAYEAwQGBwUEBAUHCAYGBwYGCAoICQkJCQgKCgwMDAwMCgwMDQ0MDBERERERFBQUFBQUFBQUFAEEBQUIBwgPCgoPFA4ODhQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQU/8AAEQgAKwCaAwERAAIRAQMRAf/EAHsAAQAABwEBAAAAAAAAAAAAAAABAwQFBgcIAgkBAQAAAAAAAAAAAAAAAAAAAAAQAAEDAwICBwYEAgsAAAAAAAIBAwQAEQUSBiEHkROTVNQWGDFBUVIUCHEiMtOUFWGBobHRQlMkZIRVEQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIRAxEAPwDSC+ygkOOaUoKigUCgUCgUCgUCgUCgUCgUCgkuGguIP9FBMFb0Hqg7We+3jlmIqqYFf4ub+/QYlnOR/LqIBKGFUbf8qWv971BytQXXE7Y3Lnm3HsFhp2TaZJAdchRXpIgSpdEJWxJEW3xoKV7F5OMy7JkQn2o7D6w33XGjEAkoiqrJEqIiOIiKuhePCgqp22dyYyS3CyWHnQ5joG61HkRnmnTbaFSMhExRVQRRVJU9iUHjE7ez+fJ0MFipmUNhBV8YUd2SoIV9KkjQla9ltegttBdPLW4/qocL+UTfrMiHW4+P9M71shuyrqaHTcxsl7jegpsji8nh5ZwMvDfgTm0RTjSmjYdFCS6KoOIipdFunCgmNYTMv457MMY6U7iI6oMieDDhRm1VbIhuoOkbqtuK0Hpzb+eZcYZexUxt6UyUqK2cd0SdjtgrhOgijcgERUlJOCIl6CpgbP3blRI8XgMjNARAyKNDfeRBdFDBVUAXgQrqH4pxoJTu2NysY97LP4ac1io5q1InHFeGO24LnVKJuKOkSQ/yKir+rh7aCLG1dzypZQI2FnvTgccYOM3FeN0XWERXAUEFVQgQkUktdLpegm+Td3/Xli/L+S/mYNJIOF9G/wBeLKrZHFb0akG6W1WtQWSg3Dyg5e7V3fipE3O4/wCrktyzYA+ufas2LbZIlmnAT2kvuoN1wft95augilglX/tzP3qCu9O3LL/wV/i5v79BvmTADq14UGu91467Z6U9y0HzH/ncj/U/sT/CgynZG7I2NezpZGUjIycJkYkZSG+uQ81pbBNKLxJfjwoMqZ3/ALYHl35AJ7/cuwHcu5k7r1Q5pHetBjquqVVJWGxj9Zrtcl/Ggy3dHMvauR3HFZj5nHNxSyW5JISYDMoIwx8tFIGHZhPNaykGapr6rUAiicEoMG21lMRj8buPAz8xhJrr7uOeiPTCyAwXUaGR1mgozbTusOsFLEiJ7fbQa/h7gcjy2H3V6xppwDNtUSxCJIqp7valBuWVzJ22xuCROXNNZiJkMtms0DbjUkAZjzoDrTMd9dDRI44ZC2YsrYdKWP2WDT2S3N9dNdlRYrGMYc06IURXSYb0igrpWS485xVNS6nF4rwslkoMwnbpgZLB7bmt5uMweAhDEl4B5uSLzzqTnnyVpW2jaJHRMSIjdDiiotvy3DOE5rYTEbkl5yFn28k7JyG4c7AU2HtLH1uKfaiMPI40CdYbpNtmLdwTSn5rewLNld+7TLdeal4WarWBkbVKBjgdElMJJwAAY5fl4kB3b1fp4XvagsGS3FjJfLzDNtS8aeXx7LzT7TyzByQE5PccRGRC0ZRUDRV6y62vbjagzLmJzS2vuPK43JY6aP1TW6Jz+RIWyFtyC06y3EkiiinAo7YCqfq1AqqnGgsOH3lhZO8d1pmcpB8j5XIm9OYlBJSQ/FSS4427DKO0RC8AlcEMhFdViRR1WDWR5t3WXVuL1d106kG9vdeye2g60+1FDyW0shIcXVpyroXt8I8dfd+NB1vioAdWnD3UF1+gD4UFc6CEKpagxXN43rwJLUHz7yX2c8zokt9uHlsPIhA4aRnnHJTLptIS6CNsY7iASpxUUMkReGpfbQW0vtN5pitvrsN28rwtBD0nc0+/Yft5XhaB6TuaXfsP28rwtA9J3NPv2H7eV4Wgek7mn37D9vK8LQPSdzT79h+3leFoHpO5pd+w/byvC0D0nc0u/Yft5XhaB6TuaXfsP28rwtA9J3NLv2H7eV4Wgek7ml37D9vK8LQPSdzS79h+3leFoHpO5p9+w/byvC0E9r7Reazy2HIYVPxkS/CUHVn26cosxyv2g7h89LYmZSXOenvLEQ1YaQ222RATcQCP8rSGqqA8S02W2pQ6FhMoAIlqCtsnwoCpdKClejI4i3Sgtb+GBxVuNBSFt1pV/RQefLjPyUDy4z8lA8uM/JQPLjPyUDy4z8lA8uM/JQPLjPyUDy4z8lA8uM/JQPLjPyUDy4z8lA8utJ/koJ7WCbBU/LQXOPAFq1koK8B0pag90CggtBBf6qB0UDooHRQOigdFA6KB0UDooHRQOigdFA6KB0UDooI0EaBQf//Z" title="Toggle Table of Contents" alt="Toggle Table of Contents" /> |
| 213 | </a> |
| 214 | </div> |
| 215 | |
| 216 | <div class="wy-grid-for-nav"> |
| 217 | |
| 218 | |
| 219 | <nav data-toggle="wy-nav-shift" class="wy-nav-side"> |
| 220 | <div class="wy-side-nav-search"> |
| 221 | |
| 222 | <a href="../index.html" class="fa fa-home"> CodeIgniter</a> |
| 223 | |
| 224 | |
| 225 | <div role="search"> |
| 226 | <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> |
| 227 | <input type="text" name="q" placeholder="Search docs" /> |
| 228 | <input type="hidden" name="check_keywords" value="yes" /> |
| 229 | <input type="hidden" name="area" value="default" /> |
| 230 | </form> |
| 231 | </div> |
| 232 | </div> |
| 233 | |
| 234 | <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> |
| 235 | |
| 236 | |
| 237 | |
| 238 | <ul> |
| 239 | <li class="toctree-l1"><a class="reference internal" href="../general/welcome.html">Welcome to CodeIgniter</a></li> |
| 240 | </ul> |
| 241 | <ul> |
| 242 | <li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation Instructions</a><ul> |
| 243 | <li class="toctree-l2"><a class="reference internal" href="../installation/downloads.html">Downloading CodeIgniter</a></li> |
| 244 | <li class="toctree-l2"><a class="reference internal" href="../installation/index.html">Installation Instructions</a></li> |
| 245 | <li class="toctree-l2"><a class="reference internal" href="../installation/upgrading.html">Upgrading From a Previous Version</a></li> |
| 246 | <li class="toctree-l2"><a class="reference internal" href="../installation/troubleshooting.html">Troubleshooting</a></li> |
| 247 | </ul> |
| 248 | </li> |
| 249 | </ul> |
| 250 | <ul> |
| 251 | <li class="toctree-l1"><a class="reference internal" href="../overview/index.html">CodeIgniter Overview</a><ul> |
| 252 | <li class="toctree-l2"><a class="reference internal" href="../overview/getting_started.html">Getting Started</a></li> |
| 253 | <li class="toctree-l2"><a class="reference internal" href="../overview/at_a_glance.html">CodeIgniter at a Glance</a></li> |
| 254 | <li class="toctree-l2"><a class="reference internal" href="../overview/features.html">Supported Features</a></li> |
| 255 | <li class="toctree-l2"><a class="reference internal" href="../overview/appflow.html">Application Flow Chart</a></li> |
| 256 | <li class="toctree-l2"><a class="reference internal" href="../overview/mvc.html">Model-View-Controller</a></li> |
| 257 | <li class="toctree-l2"><a class="reference internal" href="../overview/goals.html">Architectural Goals</a></li> |
| 258 | </ul> |
| 259 | </li> |
| 260 | </ul> |
| 261 | <ul> |
| 262 | <li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Tutorial</a><ul> |
| 263 | <li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static pages</a></li> |
| 264 | <li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News section</a></li> |
| 265 | <li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create news items</a></li> |
| 266 | <li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li> |
| 267 | </ul> |
| 268 | </li> |
| 269 | </ul> |
| 270 | <ul> |
| 271 | <li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing to CodeIgniter</a><ul> |
| 272 | <li class="toctree-l2"><a class="reference internal" href="../documentation/index.html">Writing CodeIgniter Documentation</a></li> |
| 273 | <li class="toctree-l2"><a class="reference internal" href="../DCO.html">Developer’s Certificate of Origin 1.1</a></li> |
| 274 | </ul> |
| 275 | </li> |
| 276 | </ul> |
| 277 | <ul> |
| 278 | <li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul> |
| 279 | <li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li> |
| 280 | <li class="toctree-l2"><a class="reference internal" href="../general/controllers.html">Controllers</a></li> |
| 281 | <li class="toctree-l2"><a class="reference internal" href="../general/reserved_names.html">Reserved Names</a></li> |
| 282 | <li class="toctree-l2"><a class="reference internal" href="../general/views.html">Views</a></li> |
| 283 | <li class="toctree-l2"><a class="reference internal" href="../general/models.html">Models</a></li> |
| 284 | <li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helpers</a></li> |
| 285 | <li class="toctree-l2"><a class="reference internal" href="../general/libraries.html">Using CodeIgniter Libraries</a></li> |
| 286 | <li class="toctree-l2"><a class="reference internal" href="../general/creating_libraries.html">Creating Libraries</a></li> |
| 287 | <li class="toctree-l2"><a class="reference internal" href="../general/drivers.html">Using CodeIgniter Drivers</a></li> |
| 288 | <li class="toctree-l2"><a class="reference internal" href="../general/creating_drivers.html">Creating Drivers</a></li> |
| 289 | <li class="toctree-l2"><a class="reference internal" href="../general/core_classes.html">Creating Core System Classes</a></li> |
| 290 | <li class="toctree-l2"><a class="reference internal" href="../general/ancillary_classes.html">Creating Ancillary Classes</a></li> |
| 291 | <li class="toctree-l2"><a class="reference internal" href="../general/hooks.html">Hooks - Extending the Framework Core</a></li> |
| 292 | <li class="toctree-l2"><a class="reference internal" href="../general/autoloader.html">Auto-loading Resources</a></li> |
| 293 | <li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Common Functions</a></li> |
| 294 | <li class="toctree-l2"><a class="reference internal" href="../general/compatibility_functions.html">Compatibility Functions</a></li> |
| 295 | <li class="toctree-l2"><a class="reference internal" href="../general/routing.html">URI Routing</a></li> |
| 296 | <li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li> |
| 297 | <li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Caching</a></li> |
| 298 | <li class="toctree-l2"><a class="reference internal" href="../general/profiling.html">Profiling Your Application</a></li> |
| 299 | <li class="toctree-l2"><a class="reference internal" href="../general/cli.html">Running via the CLI</a></li> |
| 300 | <li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li> |
| 301 | <li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li> |
| 302 | <li class="toctree-l2"><a class="reference internal" href="../general/alternative_php.html">Alternate PHP Syntax for View Files</a></li> |
| 303 | <li class="toctree-l2"><a class="reference internal" href="../general/security.html">Security</a></li> |
| 304 | <li class="toctree-l2"><a class="reference internal" href="../general/styleguide.html">PHP Style Guide</a></li> |
| 305 | </ul> |
| 306 | </li> |
| 307 | </ul> |
| 308 | <ul class="current"> |
| 309 | <li class="toctree-l1 current"><a class="reference internal" href="index.html">Libraries</a><ul class="current"> |
| 310 | <li class="toctree-l2"><a class="reference internal" href="benchmark.html">Benchmarking Class</a></li> |
| 311 | <li class="toctree-l2"><a class="reference internal" href="caching.html">Caching Driver</a></li> |
| 312 | <li class="toctree-l2"><a class="reference internal" href="calendar.html">Calendaring Class</a></li> |
| 313 | <li class="toctree-l2"><a class="reference internal" href="cart.html">Shopping Cart Class</a></li> |
| 314 | <li class="toctree-l2"><a class="reference internal" href="config.html">Config Class</a></li> |
| 315 | <li class="toctree-l2"><a class="reference internal" href="email.html">Email Class</a></li> |
| 316 | <li class="toctree-l2"><a class="reference internal" href="encrypt.html">Encrypt Class</a></li> |
| 317 | <li class="toctree-l2"><a class="reference internal" href="encryption.html">Encryption Library</a></li> |
| 318 | <li class="toctree-l2"><a class="reference internal" href="file_uploading.html">File Uploading Class</a></li> |
| 319 | <li class="toctree-l2"><a class="reference internal" href="form_validation.html">Form Validation</a></li> |
| 320 | <li class="toctree-l2"><a class="reference internal" href="ftp.html">FTP Class</a></li> |
| 321 | <li class="toctree-l2"><a class="reference internal" href="image_lib.html">Image Manipulation Class</a></li> |
| 322 | <li class="toctree-l2"><a class="reference internal" href="input.html">Input Class</a></li> |
| 323 | <li class="toctree-l2"><a class="reference internal" href="javascript.html">Javascript Class</a></li> |
| 324 | <li class="toctree-l2"><a class="reference internal" href="language.html">Language Class</a></li> |
| 325 | <li class="toctree-l2"><a class="reference internal" href="loader.html">Loader Class</a></li> |
| 326 | <li class="toctree-l2"><a class="reference internal" href="migration.html">Migrations Class</a></li> |
| 327 | <li class="toctree-l2"><a class="reference internal" href="output.html">Output Class</a></li> |
| 328 | <li class="toctree-l2"><a class="reference internal" href="pagination.html">Pagination Class</a></li> |
| 329 | <li class="toctree-l2"><a class="reference internal" href="parser.html">Template Parser Class</a></li> |
| 330 | <li class="toctree-l2"><a class="reference internal" href="security.html">Security Class</a></li> |
| 331 | <li class="toctree-l2 current"><a class="current reference internal" href="#">Session Library</a></li> |
| 332 | <li class="toctree-l2"><a class="reference internal" href="table.html">HTML Table Class</a></li> |
| 333 | <li class="toctree-l2"><a class="reference internal" href="trackback.html">Trackback Class</a></li> |
| 334 | <li class="toctree-l2"><a class="reference internal" href="typography.html">Typography Class</a></li> |
| 335 | <li class="toctree-l2"><a class="reference internal" href="unit_testing.html">Unit Testing Class</a></li> |
| 336 | <li class="toctree-l2"><a class="reference internal" href="uri.html">URI Class</a></li> |
| 337 | <li class="toctree-l2"><a class="reference internal" href="user_agent.html">User Agent Class</a></li> |
| 338 | <li class="toctree-l2"><a class="reference internal" href="xmlrpc.html">XML-RPC and XML-RPC Server Classes</a></li> |
| 339 | <li class="toctree-l2"><a class="reference internal" href="zip.html">Zip Encoding Class</a></li> |
| 340 | </ul> |
| 341 | </li> |
| 342 | </ul> |
| 343 | <ul> |
| 344 | <li class="toctree-l1"><a class="reference internal" href="../database/index.html">Database Reference</a><ul> |
| 345 | <li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li> |
| 346 | <li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li> |
| 347 | <li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li> |
| 348 | <li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li> |
| 349 | <li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li> |
| 350 | <li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li> |
| 351 | <li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li> |
| 352 | <li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li> |
| 353 | <li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li> |
| 354 | <li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li> |
| 355 | <li class="toctree-l2"><a class="reference internal" href="../database/caching.html">Query Caching</a></li> |
| 356 | <li class="toctree-l2"><a class="reference internal" href="../database/forge.html">Database Manipulation with Database Forge</a></li> |
| 357 | <li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities Class</a></li> |
| 358 | <li class="toctree-l2"><a class="reference internal" href="../database/db_driver_reference.html">Database Driver Reference</a></li> |
| 359 | </ul> |
| 360 | </li> |
| 361 | </ul> |
| 362 | <ul> |
| 363 | <li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul> |
| 364 | <li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li> |
| 365 | <li class="toctree-l2"><a class="reference internal" href="../helpers/captcha_helper.html">CAPTCHA Helper</a></li> |
| 366 | <li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li> |
| 367 | <li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li> |
| 368 | <li class="toctree-l2"><a class="reference internal" href="../helpers/directory_helper.html">Directory Helper</a></li> |
| 369 | <li class="toctree-l2"><a class="reference internal" href="../helpers/download_helper.html">Download Helper</a></li> |
| 370 | <li class="toctree-l2"><a class="reference internal" href="../helpers/email_helper.html">Email Helper</a></li> |
| 371 | <li class="toctree-l2"><a class="reference internal" href="../helpers/file_helper.html">File Helper</a></li> |
| 372 | <li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li> |
| 373 | <li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li> |
| 374 | <li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li> |
| 375 | <li class="toctree-l2"><a class="reference internal" href="../helpers/language_helper.html">Language Helper</a></li> |
| 376 | <li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li> |
| 377 | <li class="toctree-l2"><a class="reference internal" href="../helpers/path_helper.html">Path Helper</a></li> |
| 378 | <li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li> |
| 379 | <li class="toctree-l2"><a class="reference internal" href="../helpers/smiley_helper.html">Smiley Helper</a></li> |
| 380 | <li class="toctree-l2"><a class="reference internal" href="../helpers/string_helper.html">String Helper</a></li> |
| 381 | <li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li> |
| 382 | <li class="toctree-l2"><a class="reference internal" href="../helpers/typography_helper.html">Typography Helper</a></li> |
| 383 | <li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li> |
| 384 | <li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li> |
| 385 | </ul> |
| 386 | </li> |
| 387 | </ul> |
| 388 | |
| 389 | |
| 390 | |
| 391 | </div> |
| 392 | |
| 393 | </nav> |
| 394 | |
| 395 | <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> |
| 396 | |
| 397 | |
| 398 | <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> |
| 399 | <i data-toggle="wy-nav-top" class="fa fa-bars"></i> |
| 400 | <a href="../index.html">CodeIgniter</a> |
| 401 | </nav> |
| 402 | |
| 403 | |
| 404 | |
| 405 | <div class="wy-nav-content"> |
| 406 | <div class="rst-content"> |
| 407 | <div role="navigation" aria-label="breadcrumbs navigation"> |
| 408 | <ul class="wy-breadcrumbs"> |
| 409 | <li><a href="../index.html">Docs</a> »</li> |
| 410 | |
| 411 | <li><a href="index.html">Libraries</a> »</li> |
| 412 | |
| 413 | <li>Session Library</li> |
| 414 | <li class="wy-breadcrumbs-aside"> |
| 415 | |
| 416 | </li> |
| 417 | <div style="float:right;margin-left:5px;" id="closeMe"> |
| 418 | <img title="Classic Layout" alt="classic layout" src="data:image/gif;base64,R0lGODlhFAAUAJEAAAAAADMzM////wAAACH5BAUUAAIALAAAAAAUABQAAAImlI+py+0PU5gRBRDM3DxbWoXis42X13USOLauUIqnlsaH/eY6UwAAOw==" /> |
| 419 | </div> |
| 420 | </ul> |
| 421 | <hr/> |
| 422 | </div> |
| 423 | <div role="main" class="document"> |
| 424 | |
| 425 | <div class="section" id="session-library"> |
| 426 | <h1>Session Library<a class="headerlink" href="#session-library" title="Permalink to this headline">¶</a></h1> |
| 427 | <p>The Session class permits you maintain a user’s “state” and track their |
| 428 | activity while they browse your site.</p> |
| 429 | <p>CodeIgniter comes with a few session storage drivers:</p> |
| 430 | <blockquote> |
| 431 | <div><ul class="simple"> |
| 432 | <li>files (default; file-system based)</li> |
| 433 | <li>database</li> |
| 434 | <li>redis</li> |
| 435 | <li>memcached</li> |
| 436 | </ul> |
| 437 | </div></blockquote> |
| 438 | <p>In addition, you may create your own, custom session drivers based on other |
| 439 | kinds of storage, while still taking advantage of the features of the |
| 440 | Session class.</p> |
| 441 | <div class="contents local topic" id="contents"> |
| 442 | <ul class="simple"> |
| 443 | <li><a class="reference internal" href="#using-the-session-class" id="id3">Using the Session Class</a><ul> |
| 444 | <li><a class="reference internal" href="#initializing-a-session" id="id4">Initializing a Session</a></li> |
| 445 | <li><a class="reference internal" href="#how-do-sessions-work" id="id5">How do Sessions work?</a><ul> |
| 446 | <li><a class="reference internal" href="#a-note-about-concurrency" id="id6">A note about concurrency</a></li> |
| 447 | </ul> |
| 448 | </li> |
| 449 | <li><a class="reference internal" href="#what-is-session-data" id="id7">What is Session Data?</a></li> |
| 450 | <li><a class="reference internal" href="#retrieving-session-data" id="id8">Retrieving Session Data</a></li> |
| 451 | <li><a class="reference internal" href="#adding-session-data" id="id9">Adding Session Data</a></li> |
| 452 | <li><a class="reference internal" href="#removing-session-data" id="id10">Removing Session Data</a></li> |
| 453 | <li><a class="reference internal" href="#flashdata" id="id11">Flashdata</a></li> |
| 454 | <li><a class="reference internal" href="#tempdata" id="id12">Tempdata</a></li> |
| 455 | <li><a class="reference internal" href="#destroying-a-session" id="id13">Destroying a Session</a></li> |
| 456 | <li><a class="reference internal" href="#accessing-session-metadata" id="id14">Accessing session metadata</a></li> |
| 457 | <li><a class="reference internal" href="#session-preferences" id="id15">Session Preferences</a></li> |
| 458 | <li><a class="reference internal" href="#session-drivers" id="id16">Session Drivers</a><ul> |
| 459 | <li><a class="reference internal" href="#files-driver" id="id17">Files Driver</a><ul> |
| 460 | <li><a class="reference internal" href="#bonus-tip" id="id18">Bonus Tip</a></li> |
| 461 | </ul> |
| 462 | </li> |
| 463 | <li><a class="reference internal" href="#database-driver" id="id19">Database Driver</a></li> |
| 464 | <li><a class="reference internal" href="#redis-driver" id="id20">Redis Driver</a></li> |
| 465 | <li><a class="reference internal" href="#memcached-driver" id="id21">Memcached Driver</a><ul> |
| 466 | <li><a class="reference internal" href="#id1" id="id22">Bonus Tip</a></li> |
| 467 | </ul> |
| 468 | </li> |
| 469 | <li><a class="reference internal" href="#custom-drivers" id="id23">Custom Drivers</a></li> |
| 470 | </ul> |
| 471 | </li> |
| 472 | </ul> |
| 473 | </li> |
| 474 | <li><a class="reference internal" href="#class-reference" id="id24">Class Reference</a></li> |
| 475 | </ul> |
| 476 | </div> |
| 477 | <div class="custom-index container"></div><div class="section" id="using-the-session-class"> |
| 478 | <h2><a class="toc-backref" href="#id3">Using the Session Class</a><a class="headerlink" href="#using-the-session-class" title="Permalink to this headline">¶</a></h2> |
| 479 | <div class="section" id="initializing-a-session"> |
| 480 | <h3><a class="toc-backref" href="#id4">Initializing a Session</a><a class="headerlink" href="#initializing-a-session" title="Permalink to this headline">¶</a></h3> |
| 481 | <p>Sessions will typically run globally with each page load, so the Session |
| 482 | class should either be initialized in your <a class="reference internal" href="../general/controllers.html"><span class="doc">controller</span></a> constructors, or it can be <a class="reference internal" href="../general/autoloader.html"><span class="doc">auto-loaded</span></a> by the system. |
| 483 | For the most part the session class will run unattended in the background, |
| 484 | so simply initializing the class will cause it to read, create, and update |
| 485 | sessions when necessary.</p> |
| 486 | <p>To initialize the Session class manually in your controller constructor, |
| 487 | use the <code class="docutils literal"><span class="pre">$this->load->library()</span></code> method:</p> |
| 488 | <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">load</span><span class="o">-></span><span class="na">library</span><span class="p">(</span><span class="s1">'session'</span><span class="p">);</span> |
| 489 | </pre></div> |
| 490 | </div> |
| 491 | <p>Once loaded, the Sessions library object will be available using:</p> |
| 492 | <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">session</span> |
| 493 | </pre></div> |
| 494 | </div> |
| 495 | <div class="admonition important"> |
| 496 | <p class="first admonition-title">Important</p> |
| 497 | <p class="last">Because the <a class="reference internal" href="loader.html"><span class="doc">Loader Class</span></a> is instantiated |
| 498 | by CodeIgniter’s base controller, make sure to call |
| 499 | <code class="docutils literal"><span class="pre">parent::__construct()</span></code> before trying to load a library from |
| 500 | inside a controller constructor.</p> |
| 501 | </div> |
| 502 | </div> |
| 503 | <div class="section" id="how-do-sessions-work"> |
| 504 | <h3><a class="toc-backref" href="#id5">How do Sessions work?</a><a class="headerlink" href="#how-do-sessions-work" title="Permalink to this headline">¶</a></h3> |
| 505 | <p>When a page is loaded, the session class will check to see if valid |
| 506 | session cookie is sent by the user’s browser. If a sessions cookie does |
| 507 | <strong>not</strong> exist (or if it doesn’t match one stored on the server or has |
| 508 | expired) a new session will be created and saved.</p> |
| 509 | <p>If a valid session does exist, its information will be updated. With each |
| 510 | update, the session ID may be regenerated if configured to do so.</p> |
| 511 | <p>It’s important for you to understand that once initialized, the Session |
| 512 | class runs automatically. There is nothing you need to do to cause the |
| 513 | above behavior to happen. You can, as you’ll see below, work with session |
| 514 | data, but the process of reading, writing, and updating a session is |
| 515 | automatic.</p> |
| 516 | <div class="admonition note"> |
| 517 | <p class="first admonition-title">Note</p> |
| 518 | <p class="last">Under CLI, the Session library will automatically halt itself, |
| 519 | as this is a concept based entirely on the HTTP protocol.</p> |
| 520 | </div> |
| 521 | <div class="section" id="a-note-about-concurrency"> |
| 522 | <h4><a class="toc-backref" href="#id6">A note about concurrency</a><a class="headerlink" href="#a-note-about-concurrency" title="Permalink to this headline">¶</a></h4> |
| 523 | <p>Unless you’re developing a website with heavy AJAX usage, you can skip this |
| 524 | section. If you are, however, and if you’re experiencing performance |
| 525 | issues, then this note is exactly what you’re looking for.</p> |
| 526 | <p>Sessions in previous versions of CodeIgniter didn’t implement locking, |
| 527 | which meant that two HTTP requests using the same session could run exactly |
| 528 | at the same time. To use a more appropriate technical term - requests were |
| 529 | non-blocking.</p> |
| 530 | <p>However, non-blocking requests in the context of sessions also means |
| 531 | unsafe, because modifications to session data (or session ID regeneration) |
| 532 | in one request can interfere with the execution of a second, concurrent |
| 533 | request. This detail was at the root of many issues and the main reason why |
| 534 | CodeIgniter 3.0 has a completely re-written Session library.</p> |
| 535 | <p>Why are we telling you this? Because it is likely that after trying to |
| 536 | find the reason for your performance issues, you may conclude that locking |
| 537 | is the issue and therefore look into how to remove the locks …</p> |
| 538 | <p>DO NOT DO THAT! Removing locks would be <strong>wrong</strong> and it will cause you |
| 539 | more problems!</p> |
| 540 | <p>Locking is not the issue, it is a solution. Your issue is that you still |
| 541 | have the session open, while you’ve already processed it and therefore no |
| 542 | longer need it. So, what you need is to close the session for the |
| 543 | current request after you no longer need it.</p> |
| 544 | <p>Long story short - call <code class="docutils literal"><span class="pre">session_write_close()</span></code> once you no longer need |
| 545 | anything to do with session variables.</p> |
| 546 | </div> |
| 547 | </div> |
| 548 | <div class="section" id="what-is-session-data"> |
| 549 | <h3><a class="toc-backref" href="#id7">What is Session Data?</a><a class="headerlink" href="#what-is-session-data" title="Permalink to this headline">¶</a></h3> |
| 550 | <p>Session data is simply an array associated with a particular session ID |
| 551 | (cookie).</p> |
| 552 | <p>If you’ve used sessions in PHP before, you should be familiar with PHP’s |
| 553 | <a class="reference external" href="http://php.net/manual/en/reserved.variables.session.php">$_SESSION superglobal</a> |
| 554 | (if not, please read the content on that link).</p> |
| 555 | <p>CodeIgniter gives access to its session data through the same means, as it |
| 556 | uses the session handlers’ mechanism provided by PHP. Using session data is |
| 557 | as simple as manipulating (read, set and unset values) the <code class="docutils literal"><span class="pre">$_SESSION</span></code> |
| 558 | array.</p> |
| 559 | <p>In addition, CodeIgniter also provides 2 special types of session data |
| 560 | that are further explained below: flashdata and tempdata.</p> |
| 561 | <div class="admonition note"> |
| 562 | <p class="first admonition-title">Note</p> |
| 563 | <p class="last">In previous versions, regular session data in CodeIgniter was |
| 564 | referred to as ‘userdata’. Have this in mind if that term is used |
| 565 | elsewhere in the manual. Most of it is written to explain how |
| 566 | the custom ‘userdata’ methods work.</p> |
| 567 | </div> |
| 568 | </div> |
| 569 | <div class="section" id="retrieving-session-data"> |
| 570 | <h3><a class="toc-backref" href="#id8">Retrieving Session Data</a><a class="headerlink" href="#retrieving-session-data" title="Permalink to this headline">¶</a></h3> |
| 571 | <p>Any piece of information from the session array is available through the |
| 572 | <code class="docutils literal"><span class="pre">$_SESSION</span></code> superglobal:</p> |
| 573 | <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$_SESSION</span><span class="p">[</span><span class="s1">'item'</span><span class="p">]</span> |
| 574 | </pre></div> |
| 575 | </div> |
| 576 | <p>Or through the magic getter:</p> |
| 577 | <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">session</span><span class="o">-></span><span class="na">item</span> |
| 578 | </pre></div> |
| 579 | </div> |
| 580 | <p>And for backwards compatibility, through the <code class="docutils literal"><span class="pre">userdata()</span></code> method:</p> |
| 581 | <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">session</span><span class="o">-></span><span class="na">userdata</span><span class="p">(</span><span class="s1">'item'</span><span class="p">);</span> |
| 582 | </pre></div> |
| 583 | </div> |
| 584 | <p>Where item is the array key corresponding to the item you wish to fetch. |
| 585 | For example, to assign a previously stored ‘name’ item to the <code class="docutils literal"><span class="pre">$name</span></code> |
| 586 | variable, you will do this:</p> |
| 587 | <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$name</span> <span class="o">=</span> <span class="nv">$_SESSION</span><span class="p">[</span><span class="s1">'name'</span><span class="p">];</span> |
| 588 | |
| 589 | <span class="c1">// or:</span> |
| 590 | |
| 591 | <span class="nv">$name</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-></span><span class="na">session</span><span class="o">-></span><span class="na">name</span> |
| 592 | |
| 593 | <span class="c1">// or:</span> |
| 594 | |
| 595 | <span class="nv">$name</span> <span class="o">=</span> <span class="nv">$this</span><span class="o">-></span><span class="na">session</span><span class="o">-></span><span class="na">userdata</span><span class="p">(</span><span class="s1">'name'</span><span class="p">);</span> |
| 596 | </pre></div> |
| 597 | </div> |
| 598 | <div class="admonition note"> |
| 599 | <p class="first admonition-title">Note</p> |
| 600 | <p class="last">The <code class="docutils literal"><span class="pre">userdata()</span></code> method returns NULL if the item you are trying |
| 601 | to access does not exist.</p> |
| 602 | </div> |
| 603 | <p>If you want to retrieve all of the existing userdata, you can simply |
| 604 | omit the item key (magic getter only works for properties):</p> |
| 605 | <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$_SESSION</span> |
| 606 | |
| 607 | <span class="c1">// or:</span> |
| 608 | |
| 609 | <span class="nv">$this</span><span class="o">-></span><span class="na">session</span><span class="o">-></span><span class="na">userdata</span><span class="p">();</span> |
| 610 | </pre></div> |
| 611 | </div> |
| 612 | </div> |
| 613 | <div class="section" id="adding-session-data"> |
| 614 | <h3><a class="toc-backref" href="#id9">Adding Session Data</a><a class="headerlink" href="#adding-session-data" title="Permalink to this headline">¶</a></h3> |
| 615 | <p>Let’s say a particular user logs into your site. Once authenticated, you |
| 616 | could add their username and e-mail address to the session, making that |
| 617 | data globally available to you without having to run a database query when |
| 618 | you need it.</p> |
| 619 | <p>You can simply assign data to the <code class="docutils literal"><span class="pre">$_SESSION</span></code> array, as with any other |
| 620 | variable. Or as a property of <code class="docutils literal"><span class="pre">$this->session</span></code>.</p> |
| 621 | <p>Alternatively, the old method of assigning it as “userdata” is also |
| 622 | available. That however passing an array containing your new data to the |
| 623 | <code class="docutils literal"><span class="pre">set_userdata()</span></code> method:</p> |
| 624 | <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">session</span><span class="o">-></span><span class="na">set_userdata</span><span class="p">(</span><span class="nv">$array</span><span class="p">);</span> |
| 625 | </pre></div> |
| 626 | </div> |
| 627 | <p>Where <code class="docutils literal"><span class="pre">$array</span></code> is an associative array containing your new data. Here’s |
| 628 | an example:</p> |
| 629 | <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$newdata</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span> |
| 630 | <span class="s1">'username'</span> <span class="o">=></span> <span class="s1">'johndoe'</span><span class="p">,</span> |
| 631 | <span class="s1">'email'</span> <span class="o">=></span> <span class="s1">'johndoe@some-site.com'</span><span class="p">,</span> |
| 632 | <span class="s1">'logged_in'</span> <span class="o">=></span> <span class="k">TRUE</span> |
| 633 | <span class="p">);</span> |
| 634 | |
| 635 | <span class="nv">$this</span><span class="o">-></span><span class="na">session</span><span class="o">-></span><span class="na">set_userdata</span><span class="p">(</span><span class="nv">$newdata</span><span class="p">);</span> |
| 636 | </pre></div> |
| 637 | </div> |
| 638 | <p>If you want to add userdata one value at a time, <code class="docutils literal"><span class="pre">set_userdata()</span></code> also |
| 639 | supports this syntax:</p> |
| 640 | <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">session</span><span class="o">-></span><span class="na">set_userdata</span><span class="p">(</span><span class="s1">'some_name'</span><span class="p">,</span> <span class="s1">'some_value'</span><span class="p">);</span> |
| 641 | </pre></div> |
| 642 | </div> |
| 643 | <p>If you want to verify that a session value exists, simply check with |
| 644 | <code class="docutils literal"><span class="pre">isset()</span></code>:</p> |
| 645 | <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="c1">// returns FALSE if the 'some_name' item doesn't exist or is NULL,</span> |
| 646 | <span class="c1">// TRUE otherwise:</span> |
| 647 | <span class="nb">isset</span><span class="p">(</span><span class="nv">$_SESSION</span><span class="p">[</span><span class="s1">'some_name'</span><span class="p">])</span> |
| 648 | </pre></div> |
| 649 | </div> |
| 650 | <p>Or you can call <code class="docutils literal"><span class="pre">has_userdata()</span></code>:</p> |
| 651 | <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">session</span><span class="o">-></span><span class="na">has_userdata</span><span class="p">(</span><span class="s1">'some_name'</span><span class="p">);</span> |
| 652 | </pre></div> |
| 653 | </div> |
| 654 | </div> |
| 655 | <div class="section" id="removing-session-data"> |
| 656 | <h3><a class="toc-backref" href="#id10">Removing Session Data</a><a class="headerlink" href="#removing-session-data" title="Permalink to this headline">¶</a></h3> |
| 657 | <p>Just as with any other variable, unsetting a value in <code class="docutils literal"><span class="pre">$_SESSION</span></code> can be |
| 658 | done through <code class="docutils literal"><span class="pre">unset()</span></code>:</p> |
| 659 | <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nb">unset</span><span class="p">(</span><span class="nv">$_SESSION</span><span class="p">[</span><span class="s1">'some_name'</span><span class="p">]);</span> |
| 660 | |
| 661 | <span class="c1">// or multiple values:</span> |
| 662 | |
| 663 | <span class="nb">unset</span><span class="p">(</span> |
| 664 | <span class="nv">$_SESSION</span><span class="p">[</span><span class="s1">'some_name'</span><span class="p">],</span> |
| 665 | <span class="nv">$_SESSION</span><span class="p">[</span><span class="s1">'another_name'</span><span class="p">]</span> |
| 666 | <span class="p">);</span> |
| 667 | </pre></div> |
| 668 | </div> |
| 669 | <p>Also, just as <code class="docutils literal"><span class="pre">set_userdata()</span></code> can be used to add information to a |
| 670 | session, <code class="docutils literal"><span class="pre">unset_userdata()</span></code> can be used to remove it, by passing the |
| 671 | session key. For example, if you wanted to remove ‘some_name’ from your |
| 672 | session data array:</p> |
| 673 | <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">session</span><span class="o">-></span><span class="na">unset_userdata</span><span class="p">(</span><span class="s1">'some_name'</span><span class="p">);</span> |
| 674 | </pre></div> |
| 675 | </div> |
| 676 | <p>This method also accepts an array of item keys to unset:</p> |
| 677 | <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$array_items</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span><span class="s1">'username'</span><span class="p">,</span> <span class="s1">'email'</span><span class="p">);</span> |
| 678 | |
| 679 | <span class="nv">$this</span><span class="o">-></span><span class="na">session</span><span class="o">-></span><span class="na">unset_userdata</span><span class="p">(</span><span class="nv">$array_items</span><span class="p">);</span> |
| 680 | </pre></div> |
| 681 | </div> |
| 682 | <div class="admonition note"> |
| 683 | <p class="first admonition-title">Note</p> |
| 684 | <p class="last">In previous versions, the <code class="docutils literal"><span class="pre">unset_userdata()</span></code> method used |
| 685 | to accept an associative array of <code class="docutils literal"><span class="pre">key</span> <span class="pre">=></span> <span class="pre">'dummy</span> <span class="pre">value'</span></code> |
| 686 | pairs. This is no longer supported.</p> |
| 687 | </div> |
| 688 | </div> |
| 689 | <div class="section" id="flashdata"> |
| 690 | <h3><a class="toc-backref" href="#id11">Flashdata</a><a class="headerlink" href="#flashdata" title="Permalink to this headline">¶</a></h3> |
| 691 | <p>CodeIgniter supports “flashdata”, or session data that will only be |
| 692 | available for the next request, and is then automatically cleared.</p> |
| 693 | <p>This can be very useful, especially for one-time informational, error or |
| 694 | status messages (for example: “Record 2 deleted”).</p> |
| 695 | <p>It should be noted that flashdata variables are regular session vars, |
| 696 | only marked in a specific way under the ‘__ci_vars’ key (please don’t touch |
| 697 | that one, you’ve been warned).</p> |
| 698 | <p>To mark an existing item as “flashdata”:</p> |
| 699 | <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">session</span><span class="o">-></span><span class="na">mark_as_flash</span><span class="p">(</span><span class="s1">'item'</span><span class="p">);</span> |
| 700 | </pre></div> |
| 701 | </div> |
| 702 | <p>If you want to mark multiple items as flashdata, simply pass the keys as an |
| 703 | array:</p> |
| 704 | <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">session</span><span class="o">-></span><span class="na">mark_as_flash</span><span class="p">(</span><span class="k">array</span><span class="p">(</span><span class="s1">'item'</span><span class="p">,</span> <span class="s1">'item2'</span><span class="p">));</span> |
| 705 | </pre></div> |
| 706 | </div> |
| 707 | <p>To add flashdata:</p> |
| 708 | <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$_SESSION</span><span class="p">[</span><span class="s1">'item'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'value'</span><span class="p">;</span> |
| 709 | <span class="nv">$this</span><span class="o">-></span><span class="na">session</span><span class="o">-></span><span class="na">mark_as_flash</span><span class="p">(</span><span class="s1">'item'</span><span class="p">);</span> |
| 710 | </pre></div> |
| 711 | </div> |
| 712 | <p>Or alternatively, using the <code class="docutils literal"><span class="pre">set_flashdata()</span></code> method:</p> |
| 713 | <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">session</span><span class="o">-></span><span class="na">set_flashdata</span><span class="p">(</span><span class="s1">'item'</span><span class="p">,</span> <span class="s1">'value'</span><span class="p">);</span> |
| 714 | </pre></div> |
| 715 | </div> |
| 716 | <p>You can also pass an array to <code class="docutils literal"><span class="pre">set_flashdata()</span></code>, in the same manner as |
| 717 | <code class="docutils literal"><span class="pre">set_userdata()</span></code>.</p> |
| 718 | <p>Reading flashdata variables is the same as reading regular session data |
| 719 | through <code class="docutils literal"><span class="pre">$_SESSION</span></code>:</p> |
| 720 | <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$_SESSION</span><span class="p">[</span><span class="s1">'item'</span><span class="p">]</span> |
| 721 | </pre></div> |
| 722 | </div> |
| 723 | <div class="admonition important"> |
| 724 | <p class="first admonition-title">Important</p> |
| 725 | <p class="last">The <code class="docutils literal"><span class="pre">userdata()</span></code> method will NOT return flashdata items.</p> |
| 726 | </div> |
| 727 | <p>However, if you want to be sure that you’re reading “flashdata” (and not |
| 728 | any other kind), you can also use the <code class="docutils literal"><span class="pre">flashdata()</span></code> method:</p> |
| 729 | <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">session</span><span class="o">-></span><span class="na">flashdata</span><span class="p">(</span><span class="s1">'item'</span><span class="p">);</span> |
| 730 | </pre></div> |
| 731 | </div> |
| 732 | <p>Or to get an array with all flashdata, simply omit the key parameter:</p> |
| 733 | <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">session</span><span class="o">-></span><span class="na">flashdata</span><span class="p">();</span> |
| 734 | </pre></div> |
| 735 | </div> |
| 736 | <div class="admonition note"> |
| 737 | <p class="first admonition-title">Note</p> |
| 738 | <p class="last">The <code class="docutils literal"><span class="pre">flashdata()</span></code> method returns NULL if the item cannot be |
| 739 | found.</p> |
| 740 | </div> |
| 741 | <p>If you find that you need to preserve a flashdata variable through an |
| 742 | additional request, you can do so using the <code class="docutils literal"><span class="pre">keep_flashdata()</span></code> method. |
| 743 | You can either pass a single item or an array of flashdata items to keep.</p> |
| 744 | <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">session</span><span class="o">-></span><span class="na">keep_flashdata</span><span class="p">(</span><span class="s1">'item'</span><span class="p">);</span> |
| 745 | <span class="nv">$this</span><span class="o">-></span><span class="na">session</span><span class="o">-></span><span class="na">keep_flashdata</span><span class="p">(</span><span class="k">array</span><span class="p">(</span><span class="s1">'item1'</span><span class="p">,</span> <span class="s1">'item2'</span><span class="p">,</span> <span class="s1">'item3'</span><span class="p">));</span> |
| 746 | </pre></div> |
| 747 | </div> |
| 748 | </div> |
| 749 | <div class="section" id="tempdata"> |
| 750 | <h3><a class="toc-backref" href="#id12">Tempdata</a><a class="headerlink" href="#tempdata" title="Permalink to this headline">¶</a></h3> |
| 751 | <p>CodeIgniter also supports “tempdata”, or session data with a specific |
| 752 | expiration time. After the value expires, or the session expires or is |
| 753 | deleted, the value is automatically removed.</p> |
| 754 | <p>Similarly to flashdata, tempdata variables are regular session vars that |
| 755 | are marked in a specific way under the ‘__ci_vars’ key (again, don’t touch |
| 756 | that one).</p> |
| 757 | <p>To mark an existing item as “tempdata”, simply pass its key and expiry time |
| 758 | (in seconds!) to the <code class="docutils literal"><span class="pre">mark_as_temp()</span></code> method:</p> |
| 759 | <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="c1">// 'item' will be erased after 300 seconds</span> |
| 760 | <span class="nv">$this</span><span class="o">-></span><span class="na">session</span><span class="o">-></span><span class="na">mark_as_temp</span><span class="p">(</span><span class="s1">'item'</span><span class="p">,</span> <span class="mi">300</span><span class="p">);</span> |
| 761 | </pre></div> |
| 762 | </div> |
| 763 | <p>You can mark multiple items as tempdata in two ways, depending on whether |
| 764 | you want them all to have the same expiry time or not:</p> |
| 765 | <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="c1">// Both 'item' and 'item2' will expire after 300 seconds</span> |
| 766 | <span class="nv">$this</span><span class="o">-></span><span class="na">session</span><span class="o">-></span><span class="na">mark_as_temp</span><span class="p">(</span><span class="k">array</span><span class="p">(</span><span class="s1">'item'</span><span class="p">,</span> <span class="s1">'item2'</span><span class="p">),</span> <span class="mi">300</span><span class="p">);</span> |
| 767 | |
| 768 | <span class="c1">// 'item' will be erased after 300 seconds, while 'item2'</span> |
| 769 | <span class="c1">// will do so after only 240 seconds</span> |
| 770 | <span class="nv">$this</span><span class="o">-></span><span class="na">session</span><span class="o">-></span><span class="na">mark_as_temp</span><span class="p">(</span><span class="k">array</span><span class="p">(</span> |
| 771 | <span class="s1">'item'</span> <span class="o">=></span> <span class="mi">300</span><span class="p">,</span> |
| 772 | <span class="s1">'item2'</span> <span class="o">=></span> <span class="mi">240</span> |
| 773 | <span class="p">));</span> |
| 774 | </pre></div> |
| 775 | </div> |
| 776 | <p>To add tempdata:</p> |
| 777 | <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$_SESSION</span><span class="p">[</span><span class="s1">'item'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'value'</span><span class="p">;</span> |
| 778 | <span class="nv">$this</span><span class="o">-></span><span class="na">session</span><span class="o">-></span><span class="na">mark_as_temp</span><span class="p">(</span><span class="s1">'item'</span><span class="p">,</span> <span class="mi">300</span><span class="p">);</span> <span class="c1">// Expire in 5 minutes</span> |
| 779 | </pre></div> |
| 780 | </div> |
| 781 | <p>Or alternatively, using the <code class="docutils literal"><span class="pre">set_tempdata()</span></code> method:</p> |
| 782 | <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">session</span><span class="o">-></span><span class="na">set_tempdata</span><span class="p">(</span><span class="s1">'item'</span><span class="p">,</span> <span class="s1">'value'</span><span class="p">,</span> <span class="mi">300</span><span class="p">);</span> |
| 783 | </pre></div> |
| 784 | </div> |
| 785 | <p>You can also pass an array to <code class="docutils literal"><span class="pre">set_tempdata()</span></code>:</p> |
| 786 | <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$tempdata</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span><span class="s1">'newuser'</span> <span class="o">=></span> <span class="k">TRUE</span><span class="p">,</span> <span class="s1">'message'</span> <span class="o">=></span> <span class="s1">'Thanks for joining!'</span><span class="p">);</span> |
| 787 | |
| 788 | <span class="nv">$this</span><span class="o">-></span><span class="na">session</span><span class="o">-></span><span class="na">set_tempdata</span><span class="p">(</span><span class="nv">$tempdata</span><span class="p">,</span> <span class="k">NULL</span><span class="p">,</span> <span class="nv">$expire</span><span class="p">);</span> |
| 789 | </pre></div> |
| 790 | </div> |
| 791 | <div class="admonition note"> |
| 792 | <p class="first admonition-title">Note</p> |
| 793 | <p class="last">If the expiration is omitted or set to 0, the default |
| 794 | time-to-live value of 300 seconds (or 5 minutes) will be used.</p> |
| 795 | </div> |
| 796 | <p>To read a tempdata variable, again you can just access it through the |
| 797 | <code class="docutils literal"><span class="pre">$_SESSION</span></code> superglobal array:</p> |
| 798 | <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$_SESSION</span><span class="p">[</span><span class="s1">'item'</span><span class="p">]</span> |
| 799 | </pre></div> |
| 800 | </div> |
| 801 | <div class="admonition important"> |
| 802 | <p class="first admonition-title">Important</p> |
| 803 | <p class="last">The <code class="docutils literal"><span class="pre">userdata()</span></code> method will NOT return tempdata items.</p> |
| 804 | </div> |
| 805 | <p>Or if you want to be sure that you’re reading “tempdata” (and not any |
| 806 | other kind), you can also use the <code class="docutils literal"><span class="pre">tempdata()</span></code> method:</p> |
| 807 | <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">session</span><span class="o">-></span><span class="na">tempdata</span><span class="p">(</span><span class="s1">'item'</span><span class="p">);</span> |
| 808 | </pre></div> |
| 809 | </div> |
| 810 | <p>And of course, if you want to retrieve all existing tempdata:</p> |
| 811 | <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">session</span><span class="o">-></span><span class="na">tempdata</span><span class="p">();</span> |
| 812 | </pre></div> |
| 813 | </div> |
| 814 | <div class="admonition note"> |
| 815 | <p class="first admonition-title">Note</p> |
| 816 | <p class="last">The <code class="docutils literal"><span class="pre">tempdata()</span></code> method returns NULL if the item cannot be |
| 817 | found.</p> |
| 818 | </div> |
| 819 | <p>If you need to remove a tempdata value before it expires, you can directly |
| 820 | unset it from the <code class="docutils literal"><span class="pre">$_SESSION</span></code> array:</p> |
| 821 | <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nb">unset</span><span class="p">(</span><span class="nv">$_SESSION</span><span class="p">[</span><span class="s1">'item'</span><span class="p">]);</span> |
| 822 | </pre></div> |
| 823 | </div> |
| 824 | <p>However, this won’t remove the marker that makes this specific item to be |
| 825 | tempdata (it will be invalidated on the next HTTP request), so if you |
| 826 | intend to reuse that same key in the same request, you’d want to use |
| 827 | <code class="docutils literal"><span class="pre">unset_tempdata()</span></code>:</p> |
| 828 | <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">session</span><span class="o">-></span><span class="na">unset_tempdata</span><span class="p">(</span><span class="s1">'item'</span><span class="p">);</span> |
| 829 | </pre></div> |
| 830 | </div> |
| 831 | </div> |
| 832 | <div class="section" id="destroying-a-session"> |
| 833 | <h3><a class="toc-backref" href="#id13">Destroying a Session</a><a class="headerlink" href="#destroying-a-session" title="Permalink to this headline">¶</a></h3> |
| 834 | <p>To clear the current session (for example, during a logout), you may |
| 835 | simply use either PHP’s <a class="reference external" href="http://php.net/session_destroy">session_destroy()</a> |
| 836 | function, or the <code class="docutils literal"><span class="pre">sess_destroy()</span></code> method. Both will work in exactly the |
| 837 | same way:</p> |
| 838 | <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nb">session_destroy</span><span class="p">();</span> |
| 839 | |
| 840 | <span class="c1">// or</span> |
| 841 | |
| 842 | <span class="nv">$this</span><span class="o">-></span><span class="na">session</span><span class="o">-></span><span class="na">sess_destroy</span><span class="p">();</span> |
| 843 | </pre></div> |
| 844 | </div> |
| 845 | <div class="admonition note"> |
| 846 | <p class="first admonition-title">Note</p> |
| 847 | <p class="last">This must be the last session-related operation that you do |
| 848 | during the same request. All session data (including flashdata and |
| 849 | tempdata) will be destroyed permanently and functions will be |
| 850 | unusable during the same request after you destroy the session.</p> |
| 851 | </div> |
| 852 | </div> |
| 853 | <div class="section" id="accessing-session-metadata"> |
| 854 | <h3><a class="toc-backref" href="#id14">Accessing session metadata</a><a class="headerlink" href="#accessing-session-metadata" title="Permalink to this headline">¶</a></h3> |
| 855 | <p>In previous CodeIgniter versions, the session data array included 4 items |
| 856 | by default: ‘session_id’, ‘ip_address’, ‘user_agent’, ‘last_activity’.</p> |
| 857 | <p>This was due to the specifics of how sessions worked, but is now no longer |
| 858 | necessary with our new implementation. However, it may happen that your |
| 859 | application relied on these values, so here are alternative methods of |
| 860 | accessing them:</p> |
| 861 | <blockquote> |
| 862 | <div><ul class="simple"> |
| 863 | <li>session_id: <code class="docutils literal"><span class="pre">session_id()</span></code></li> |
| 864 | <li>ip_address: <code class="docutils literal"><span class="pre">$_SERVER['REMOTE_ADDR']</span></code></li> |
| 865 | <li>user_agent: <code class="docutils literal"><span class="pre">$this->input->user_agent()</span></code> (unused by sessions)</li> |
| 866 | <li>last_activity: Depends on the storage, no straightforward way. Sorry!</li> |
| 867 | </ul> |
| 868 | </div></blockquote> |
| 869 | </div> |
| 870 | <div class="section" id="session-preferences"> |
| 871 | <h3><a class="toc-backref" href="#id15">Session Preferences</a><a class="headerlink" href="#session-preferences" title="Permalink to this headline">¶</a></h3> |
| 872 | <p>CodeIgniter will usually make everything work out of the box. However, |
| 873 | Sessions are a very sensitive component of any application, so some |
| 874 | careful configuration must be done. Please take your time to consider |
| 875 | all of the options and their effects.</p> |
| 876 | <p>You’ll find the following Session related preferences in your |
| 877 | <strong>application/config/config.php</strong> file:</p> |
| 878 | <table border="1" class="docutils"> |
| 879 | <colgroup> |
| 880 | <col width="16%" /> |
| 881 | <col width="9%" /> |
| 882 | <col width="23%" /> |
| 883 | <col width="53%" /> |
| 884 | </colgroup> |
| 885 | <thead valign="bottom"> |
| 886 | <tr class="row-odd"><th class="head">Preference</th> |
| 887 | <th class="head">Default</th> |
| 888 | <th class="head">Options</th> |
| 889 | <th class="head">Description</th> |
| 890 | </tr> |
| 891 | </thead> |
| 892 | <tbody valign="top"> |
| 893 | <tr class="row-even"><td><strong>sess_driver</strong></td> |
| 894 | <td>files</td> |
| 895 | <td>files/database/redis/memcached/<em>custom</em></td> |
| 896 | <td>The session storage driver to use.</td> |
| 897 | </tr> |
| 898 | <tr class="row-odd"><td><strong>sess_cookie_name</strong></td> |
| 899 | <td>ci_session</td> |
| 900 | <td>[A-Za-z_-] characters only</td> |
| 901 | <td>The name used for the session cookie.</td> |
| 902 | </tr> |
| 903 | <tr class="row-even"><td><strong>sess_expiration</strong></td> |
| 904 | <td>7200 (2 hours)</td> |
| 905 | <td>Time in seconds (integer)</td> |
| 906 | <td>The number of seconds you would like the session to last. |
| 907 | If you would like a non-expiring session (until browser is closed) set the value to zero: 0</td> |
| 908 | </tr> |
| 909 | <tr class="row-odd"><td><strong>sess_save_path</strong></td> |
| 910 | <td>NULL</td> |
| 911 | <td>None</td> |
| 912 | <td>Specifies the storage location, depends on the driver being used.</td> |
| 913 | </tr> |
| 914 | <tr class="row-even"><td><strong>sess_match_ip</strong></td> |
| 915 | <td>FALSE</td> |
| 916 | <td>TRUE/FALSE (boolean)</td> |
| 917 | <td>Whether to validate the user’s IP address when reading the session cookie. |
| 918 | Note that some ISPs dynamically changes the IP, so if you want a non-expiring session you |
| 919 | will likely set this to FALSE.</td> |
| 920 | </tr> |
| 921 | <tr class="row-odd"><td><strong>sess_time_to_update</strong></td> |
| 922 | <td>300</td> |
| 923 | <td>Time in seconds (integer)</td> |
| 924 | <td>This option controls how often the session class will regenerate itself and create a new |
| 925 | session ID. Setting it to 0 will disable session ID regeneration.</td> |
| 926 | </tr> |
| 927 | <tr class="row-even"><td><strong>sess_regenerate_destroy</strong></td> |
| 928 | <td>FALSE</td> |
| 929 | <td>TRUE/FALSE (boolean)</td> |
| 930 | <td>Whether to destroy session data associated with the old session ID when auto-regenerating |
| 931 | the session ID. When set to FALSE, the data will be later deleted by the garbage collector.</td> |
| 932 | </tr> |
| 933 | </tbody> |
| 934 | </table> |
| 935 | <div class="admonition note"> |
| 936 | <p class="first admonition-title">Note</p> |
| 937 | <p class="last">As a last resort, the Session library will try to fetch PHP’s |
| 938 | session related INI settings, as well as legacy CI settings such as |
| 939 | ‘sess_expire_on_close’ when any of the above is not configured. |
| 940 | However, you should never rely on this behavior as it can cause |
| 941 | unexpected results or be changed in the future. Please configure |
| 942 | everything properly.</p> |
| 943 | </div> |
| 944 | <p>In addition to the values above, the cookie and native drivers apply the |
| 945 | following configuration values shared by the <a class="reference internal" href="input.html"><span class="doc">Input</span></a> and |
| 946 | <a class="reference internal" href="security.html"><span class="doc">Security</span></a> classes:</p> |
| 947 | <table border="1" class="docutils"> |
| 948 | <colgroup> |
| 949 | <col width="17%" /> |
| 950 | <col width="14%" /> |
| 951 | <col width="69%" /> |
| 952 | </colgroup> |
| 953 | <thead valign="bottom"> |
| 954 | <tr class="row-odd"><th class="head">Preference</th> |
| 955 | <th class="head">Default</th> |
| 956 | <th class="head">Description</th> |
| 957 | </tr> |
| 958 | </thead> |
| 959 | <tbody valign="top"> |
| 960 | <tr class="row-even"><td><strong>cookie_domain</strong></td> |
| 961 | <td>‘’</td> |
| 962 | <td>The domain for which the session is applicable</td> |
| 963 | </tr> |
| 964 | <tr class="row-odd"><td><strong>cookie_path</strong></td> |
| 965 | <td>/</td> |
| 966 | <td>The path to which the session is applicable</td> |
| 967 | </tr> |
| 968 | <tr class="row-even"><td><strong>cookie_secure</strong></td> |
| 969 | <td>FALSE</td> |
| 970 | <td>Whether to create the session cookie only on encrypted (HTTPS) connections</td> |
| 971 | </tr> |
| 972 | </tbody> |
| 973 | </table> |
| 974 | <div class="admonition note"> |
| 975 | <p class="first admonition-title">Note</p> |
| 976 | <p class="last">The ‘cookie_httponly’ setting doesn’t have an effect on sessions. |
| 977 | Instead the HttpOnly parameter is always enabled, for security |
| 978 | reasons. Additionally, the ‘cookie_prefix’ setting is completely |
| 979 | ignored.</p> |
| 980 | </div> |
| 981 | </div> |
| 982 | <div class="section" id="session-drivers"> |
| 983 | <h3><a class="toc-backref" href="#id16">Session Drivers</a><a class="headerlink" href="#session-drivers" title="Permalink to this headline">¶</a></h3> |
| 984 | <p>As already mentioned, the Session library comes with 4 drivers, or storage |
| 985 | engines, that you can use:</p> |
| 986 | <blockquote> |
| 987 | <div><ul class="simple"> |
| 988 | <li>files</li> |
| 989 | <li>database</li> |
| 990 | <li>redis</li> |
| 991 | <li>memcached</li> |
| 992 | </ul> |
| 993 | </div></blockquote> |
| 994 | <p>By default, the <a class="reference internal" href="#files-driver">Files Driver</a> will be used when a session is initialized, |
| 995 | because it is the most safe choice and is expected to work everywhere |
| 996 | (virtually every environment has a file system).</p> |
| 997 | <p>However, any other driver may be selected via the <code class="docutils literal"><span class="pre">$config['sess_driver']</span></code> |
| 998 | line in your <strong>application/config/config.php</strong> file, if you chose to do so. |
| 999 | Have it in mind though, every driver has different caveats, so be sure to |
| 1000 | get yourself familiar with them (below) before you make that choice.</p> |
| 1001 | <p>In addition, you may also create and use <a class="reference internal" href="#custom-drivers">Custom Drivers</a>, if the ones |
| 1002 | provided by default don’t satisfy your use case.</p> |
| 1003 | <div class="admonition note"> |
| 1004 | <p class="first admonition-title">Note</p> |
| 1005 | <p class="last">In previous CodeIgniter versions, a different, “cookie driver” |
| 1006 | was the only option and we have received negative feedback on not |
| 1007 | providing that option. While we do listen to feedback from the |
| 1008 | community, we want to warn you that it was dropped because it is |
| 1009 | <strong>unsafe</strong> and we advise you NOT to try to replicate it via a |
| 1010 | custom driver.</p> |
| 1011 | </div> |
| 1012 | <div class="section" id="files-driver"> |
| 1013 | <h4><a class="toc-backref" href="#id17">Files Driver</a><a class="headerlink" href="#files-driver" title="Permalink to this headline">¶</a></h4> |
| 1014 | <p>The ‘files’ driver uses your file system for storing session data.</p> |
| 1015 | <p>It can safely be said that it works exactly like PHP’s own default session |
| 1016 | implementation, but in case this is an important detail for you, have it |
| 1017 | mind that it is in fact not the same code and it has some limitations |
| 1018 | (and advantages).</p> |
| 1019 | <p>To be more specific, it doesn’t support PHP’s <a class="reference external" href="http://php.net/manual/en/session.configuration.php#ini.session.save-path">directory level and mode |
| 1020 | formats used in session.save_path</a>, |
| 1021 | and it has most of the options hard-coded for safety. Instead, only |
| 1022 | absolute paths are supported for <code class="docutils literal"><span class="pre">$config['sess_save_path']</span></code>.</p> |
| 1023 | <p>Another important thing that you should know, is to make sure that you |
| 1024 | don’t use a publicly-readable or shared directory for storing your session |
| 1025 | files. Make sure that <em>only you</em> have access to see the contents of your |
| 1026 | chosen <em>sess_save_path</em> directory. Otherwise, anybody who can do that, can |
| 1027 | also steal any of the current sessions (also known as “session fixation” |
| 1028 | attack).</p> |
| 1029 | <p>On UNIX-like operating systems, this is usually achieved by setting the |
| 1030 | 0700 mode permissions on that directory via the <cite>chmod</cite> command, which |
| 1031 | allows only the directory’s owner to perform read and write operations on |
| 1032 | it. But be careful because the system user <em>running</em> the script is usually |
| 1033 | not your own, but something like ‘www-data’ instead, so only setting those |
| 1034 | permissions will probable break your application.</p> |
| 1035 | <p>Instead, you should do something like this, depending on your environment</p> |
| 1036 | <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nb">mkdir</span> <span class="o">/<</span><span class="nx">path</span> <span class="nx">to</span> <span class="nx">your</span> <span class="nx">application</span> <span class="nx">directory</span><span class="o">>/</span><span class="nx">sessions</span><span class="o">/</span> |
| 1037 | <span class="nb">chmod</span> <span class="mo">0700</span> <span class="o">/<</span><span class="nx">path</span> <span class="nx">to</span> <span class="nx">your</span> <span class="nx">application</span> <span class="nx">directory</span><span class="o">>/</span><span class="nx">sessions</span><span class="o">/</span> |
| 1038 | <span class="nb">chown</span> <span class="nx">www</span><span class="o">-</span><span class="nx">data</span> <span class="o">/<</span><span class="nx">path</span> <span class="nx">to</span> <span class="nx">your</span> <span class="nx">application</span> <span class="nx">directory</span><span class="o">>/</span><span class="nx">sessions</span><span class="o">/</span> |
| 1039 | </pre></div> |
| 1040 | </div> |
| 1041 | <div class="section" id="bonus-tip"> |
| 1042 | <h5><a class="toc-backref" href="#id18">Bonus Tip</a><a class="headerlink" href="#bonus-tip" title="Permalink to this headline">¶</a></h5> |
| 1043 | <p>Some of you will probably opt to choose another session driver because |
| 1044 | file storage is usually slower. This is only half true.</p> |
| 1045 | <p>A very basic test will probably trick you into believing that an SQL |
| 1046 | database is faster, but in 99% of the cases, this is only true while you |
| 1047 | only have a few current sessions. As the sessions count and server loads |
| 1048 | increase - which is the time when it matters - the file system will |
| 1049 | consistently outperform almost all relational database setups.</p> |
| 1050 | <p>In addition, if performance is your only concern, you may want to look |
| 1051 | into using <a class="reference external" href="http://eddmann.com/posts/storing-php-sessions-file-caches-in-memory-using-tmpfs/">tmpfs</a>, |
| 1052 | (warning: external resource), which can make your sessions blazing fast.</p> |
| 1053 | </div> |
| 1054 | </div> |
| 1055 | <div class="section" id="database-driver"> |
| 1056 | <h4><a class="toc-backref" href="#id19">Database Driver</a><a class="headerlink" href="#database-driver" title="Permalink to this headline">¶</a></h4> |
| 1057 | <p>The ‘database’ driver uses a relational database such as MySQL or |
| 1058 | PostgreSQL to store sessions. This is a popular choice among many users, |
| 1059 | because it allows the developer easy access to the session data within |
| 1060 | an application - it is just another table in your database.</p> |
| 1061 | <p>However, there are some conditions that must be met:</p> |
| 1062 | <blockquote> |
| 1063 | <div><ul class="simple"> |
| 1064 | <li>Only your <strong>default</strong> database connection (or the one that you access |
| 1065 | as <code class="docutils literal"><span class="pre">$this->db</span></code> from your controllers) can be used.</li> |
| 1066 | <li>You must have the <a class="reference internal" href="../database/query_builder.html"><span class="doc">Query Builder</span></a> |
| 1067 | enabled.</li> |
| 1068 | <li>You can NOT use a persistent connection.</li> |
| 1069 | <li>You can NOT use a connection with the <em>cache_on</em> setting enabled.</li> |
| 1070 | </ul> |
| 1071 | </div></blockquote> |
| 1072 | <p>In order to use the ‘database’ session driver, you must also create this |
| 1073 | table that we already mentioned and then set it as your |
| 1074 | <code class="docutils literal"><span class="pre">$config['sess_save_path']</span></code> value. |
| 1075 | For example, if you would like to use ‘ci_sessions’ as your table name, |
| 1076 | you would do this:</p> |
| 1077 | <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$config</span><span class="p">[</span><span class="s1">'sess_driver'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'database'</span><span class="p">;</span> |
| 1078 | <span class="nv">$config</span><span class="p">[</span><span class="s1">'sess_save_path'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'ci_sessions'</span><span class="p">;</span> |
| 1079 | </pre></div> |
| 1080 | </div> |
| 1081 | <div class="admonition note"> |
| 1082 | <p class="first admonition-title">Note</p> |
| 1083 | <p class="last">If you’ve upgraded from a previous version of CodeIgniter and |
| 1084 | you don’t have ‘sess_save_path’ configured, then the Session |
| 1085 | library will look for the old ‘sess_table_name’ setting and use |
| 1086 | it instead. Please don’t rely on this behavior as it will get |
| 1087 | removed in the future.</p> |
| 1088 | </div> |
| 1089 | <p>And then of course, create the database table …</p> |
| 1090 | <p>For MySQL:</p> |
| 1091 | <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nx">CREATE</span> <span class="nx">TABLE</span> <span class="k">IF</span> <span class="k">NOT</span> <span class="nx">EXISTS</span> <span class="sb">`ci_sessions`</span> <span class="p">(</span> |
| 1092 | <span class="sb">`id`</span> <span class="nx">varchar</span><span class="p">(</span><span class="mi">128</span><span class="p">)</span> <span class="k">NOT</span> <span class="k">NULL</span><span class="p">,</span> |
| 1093 | <span class="sb">`ip_address`</span> <span class="nx">varchar</span><span class="p">(</span><span class="mi">45</span><span class="p">)</span> <span class="k">NOT</span> <span class="k">NULL</span><span class="p">,</span> |
| 1094 | <span class="sb">`timestamp`</span> <span class="nx">int</span><span class="p">(</span><span class="mi">10</span><span class="p">)</span> <span class="nx">unsigned</span> <span class="k">DEFAULT</span> <span class="mi">0</span> <span class="k">NOT</span> <span class="k">NULL</span><span class="p">,</span> |
| 1095 | <span class="sb">`data`</span> <span class="nx">blob</span> <span class="k">NOT</span> <span class="k">NULL</span><span class="p">,</span> |
| 1096 | <span class="nx">KEY</span> <span class="sb">`ci_sessions_timestamp`</span> <span class="p">(</span><span class="sb">`timestamp`</span><span class="p">)</span> |
| 1097 | <span class="p">);</span> |
| 1098 | </pre></div> |
| 1099 | </div> |
| 1100 | <p>For PostgreSQL:</p> |
| 1101 | <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nx">CREATE</span> <span class="nx">TABLE</span> <span class="s2">"ci_sessions"</span> <span class="p">(</span> |
| 1102 | <span class="s2">"id"</span> <span class="nx">varchar</span><span class="p">(</span><span class="mi">128</span><span class="p">)</span> <span class="k">NOT</span> <span class="k">NULL</span><span class="p">,</span> |
| 1103 | <span class="s2">"ip_address"</span> <span class="nx">varchar</span><span class="p">(</span><span class="mi">45</span><span class="p">)</span> <span class="k">NOT</span> <span class="k">NULL</span><span class="p">,</span> |
| 1104 | <span class="s2">"timestamp"</span> <span class="nx">bigint</span> <span class="k">DEFAULT</span> <span class="mi">0</span> <span class="k">NOT</span> <span class="k">NULL</span><span class="p">,</span> |
| 1105 | <span class="s2">"data"</span> <span class="nx">text</span> <span class="k">DEFAULT</span> <span class="s1">''</span> <span class="k">NOT</span> <span class="k">NULL</span> |
| 1106 | <span class="p">);</span> |
| 1107 | |
| 1108 | <span class="nx">CREATE</span> <span class="nx">INDEX</span> <span class="s2">"ci_sessions_timestamp"</span> <span class="nx">ON</span> <span class="s2">"ci_sessions"</span> <span class="p">(</span><span class="s2">"timestamp"</span><span class="p">);</span> |
| 1109 | </pre></div> |
| 1110 | </div> |
| 1111 | <p>You will also need to add a PRIMARY KEY <strong>depending on your ‘sess_match_ip’ |
| 1112 | setting</strong>. The examples below work both on MySQL and PostgreSQL:</p> |
| 1113 | <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="c1">// When sess_match_ip = TRUE</span> |
| 1114 | <span class="nx">ALTER</span> <span class="nx">TABLE</span> <span class="nx">ci_sessions</span> <span class="nx">ADD</span> <span class="nx">PRIMARY</span> <span class="nx">KEY</span> <span class="p">(</span><span class="nx">id</span><span class="p">,</span> <span class="nx">ip_address</span><span class="p">);</span> |
| 1115 | |
| 1116 | <span class="c1">// When sess_match_ip = FALSE</span> |
| 1117 | <span class="nx">ALTER</span> <span class="nx">TABLE</span> <span class="nx">ci_sessions</span> <span class="nx">ADD</span> <span class="nx">PRIMARY</span> <span class="nx">KEY</span> <span class="p">(</span><span class="nx">id</span><span class="p">);</span> |
| 1118 | |
| 1119 | <span class="c1">// To drop a previously created primary key (use when changing the setting)</span> |
| 1120 | <span class="nx">ALTER</span> <span class="nx">TABLE</span> <span class="nx">ci_sessions</span> <span class="nx">DROP</span> <span class="nx">PRIMARY</span> <span class="nx">KEY</span><span class="p">;</span> |
| 1121 | </pre></div> |
| 1122 | </div> |
| 1123 | <div class="admonition important"> |
| 1124 | <p class="first admonition-title">Important</p> |
| 1125 | <p class="last">Only MySQL and PostgreSQL databases are officially |
| 1126 | supported, due to lack of advisory locking mechanisms on other |
| 1127 | platforms. Using sessions without locks can cause all sorts of |
| 1128 | problems, especially with heavy usage of AJAX, and we will not |
| 1129 | support such cases. Use <code class="docutils literal"><span class="pre">session_write_close()</span></code> after you’ve |
| 1130 | done processing session data if you’re having performance |
| 1131 | issues.</p> |
| 1132 | </div> |
| 1133 | </div> |
| 1134 | <div class="section" id="redis-driver"> |
| 1135 | <h4><a class="toc-backref" href="#id20">Redis Driver</a><a class="headerlink" href="#redis-driver" title="Permalink to this headline">¶</a></h4> |
| 1136 | <div class="admonition note"> |
| 1137 | <p class="first admonition-title">Note</p> |
| 1138 | <p class="last">Since Redis doesn’t have a locking mechanism exposed, locks for |
| 1139 | this driver are emulated by a separate value that is kept for up |
| 1140 | to 300 seconds.</p> |
| 1141 | </div> |
| 1142 | <p>Redis is a storage engine typically used for caching and popular because |
| 1143 | of its high performance, which is also probably your reason to use the |
| 1144 | ‘redis’ session driver.</p> |
| 1145 | <p>The downside is that it is not as ubiquitous as relational databases and |
| 1146 | requires the <a class="reference external" href="https://github.com/phpredis/phpredis">phpredis</a> PHP |
| 1147 | extension to be installed on your system, and that one doesn’t come |
| 1148 | bundled with PHP. |
| 1149 | Chances are, you’re only be using the ‘redis’ driver only if you’re already |
| 1150 | both familiar with Redis and using it for other purposes.</p> |
| 1151 | <p>Just as with the ‘files’ and ‘database’ drivers, you must also configure |
| 1152 | the storage location for your sessions via the |
| 1153 | <code class="docutils literal"><span class="pre">$config['sess_save_path']</span></code> setting. |
| 1154 | The format here is a bit different and complicated at the same time. It is |
| 1155 | best explained by the <em>phpredis</em> extension’s README file, so we’ll simply |
| 1156 | link you to it:</p> |
| 1157 | <blockquote> |
| 1158 | <div><a class="reference external" href="https://github.com/phpredis/phpredis#php-session-handler">https://github.com/phpredis/phpredis#php-session-handler</a></div></blockquote> |
| 1159 | <div class="admonition warning"> |
| 1160 | <p class="first admonition-title">Warning</p> |
| 1161 | <p class="last">CodeIgniter’s Session library does NOT use the actual ‘redis’ |
| 1162 | <code class="docutils literal"><span class="pre">session.save_handler</span></code>. Take note <strong>only</strong> of the path format in |
| 1163 | the link above.</p> |
| 1164 | </div> |
| 1165 | <p>For the most common case however, a simple <code class="docutils literal"><span class="pre">host:port</span></code> pair should be |
| 1166 | sufficient:</p> |
| 1167 | <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$config</span><span class="p">[</span><span class="s1">'sess_driver'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'redis'</span><span class="p">;</span> |
| 1168 | <span class="nv">$config</span><span class="p">[</span><span class="s1">'sess_save_path'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'tcp://localhost:6379'</span><span class="p">;</span> |
| 1169 | </pre></div> |
| 1170 | </div> |
| 1171 | </div> |
| 1172 | <div class="section" id="memcached-driver"> |
| 1173 | <h4><a class="toc-backref" href="#id21">Memcached Driver</a><a class="headerlink" href="#memcached-driver" title="Permalink to this headline">¶</a></h4> |
| 1174 | <div class="admonition note"> |
| 1175 | <p class="first admonition-title">Note</p> |
| 1176 | <p class="last">Since Memcache doesn’t have a locking mechanism exposed, locks |
| 1177 | for this driver are emulated by a separate value that is kept for |
| 1178 | up to 300 seconds.</p> |
| 1179 | </div> |
| 1180 | <p>The ‘memcached’ driver is very similar to the ‘redis’ one in all of its |
| 1181 | properties, except perhaps for availability, because PHP’s <a class="reference external" href="http://php.net/memcached">Memcached</a> extension is distributed via PECL and some |
| 1182 | Linux distrubutions make it available as an easy to install package.</p> |
| 1183 | <p>Other than that, and without any intentional bias towards Redis, there’s |
| 1184 | not much different to be said about Memcached - it is also a popular |
| 1185 | product that is usually used for caching and famed for its speed.</p> |
| 1186 | <p>However, it is worth noting that the only guarantee given by Memcached |
| 1187 | is that setting value X to expire after Y seconds will result in it being |
| 1188 | deleted after Y seconds have passed (but not necessarily that it won’t |
| 1189 | expire earlier than that time). This happens very rarely, but should be |
| 1190 | considered as it may result in loss of sessions.</p> |
| 1191 | <p>The <code class="docutils literal"><span class="pre">$config['sess_save_path']</span></code> format is fairly straightforward here, |
| 1192 | being just a <code class="docutils literal"><span class="pre">host:port</span></code> pair:</p> |
| 1193 | <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$config</span><span class="p">[</span><span class="s1">'sess_driver'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'memcached'</span><span class="p">;</span> |
| 1194 | <span class="nv">$config</span><span class="p">[</span><span class="s1">'sess_save_path'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'localhost:11211'</span><span class="p">;</span> |
| 1195 | </pre></div> |
| 1196 | </div> |
| 1197 | <div class="section" id="id1"> |
| 1198 | <h5><a class="toc-backref" href="#id22">Bonus Tip</a><a class="headerlink" href="#id1" title="Permalink to this headline">¶</a></h5> |
| 1199 | <p>Multi-server configuration with an optional <em>weight</em> parameter as the |
| 1200 | third colon-separated (<code class="docutils literal"><span class="pre">:weight</span></code>) value is also supported, but we have |
| 1201 | to note that we haven’t tested if that is reliable.</p> |
| 1202 | <p>If you want to experiment with this feature (on your own risk), simply |
| 1203 | separate the multiple server paths with commas:</p> |
| 1204 | <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="c1">// localhost will be given higher priority (5) here,</span> |
| 1205 | <span class="c1">// compared to 192.0.2.1 with a weight of 1.</span> |
| 1206 | <span class="nv">$config</span><span class="p">[</span><span class="s1">'sess_save_path'</span><span class="p">]</span> <span class="o">=</span> <span class="s1">'localhost:11211:5,192.0.2.1:11211:1'</span><span class="p">;</span> |
| 1207 | </pre></div> |
| 1208 | </div> |
| 1209 | </div> |
| 1210 | </div> |
| 1211 | <div class="section" id="custom-drivers"> |
| 1212 | <h4><a class="toc-backref" href="#id23">Custom Drivers</a><a class="headerlink" href="#custom-drivers" title="Permalink to this headline">¶</a></h4> |
| 1213 | <p>You may also create your own, custom session drivers. However, have it in |
| 1214 | mind that this is typically not an easy task, as it takes a lot of |
| 1215 | knowledge to do it properly.</p> |
| 1216 | <p>You need to know not only how sessions work in general, but also how they |
| 1217 | work specifically in PHP, how the underlying storage mechanism works, how |
| 1218 | to handle concurrency, avoid deadlocks (but NOT through lack of locks) and |
| 1219 | last but not least - how to handle the potential security issues, which |
| 1220 | is far from trivial.</p> |
| 1221 | <p>Long story short - if you don’t know how to do that already in raw PHP, |
| 1222 | you shouldn’t be trying to do it within CodeIgniter either. You’ve been |
| 1223 | warned.</p> |
| 1224 | <p>If you only want to add some extra functionality to your sessions, just |
| 1225 | extend the base Session class, which is a lot more easier. Read the |
| 1226 | <a class="reference internal" href="../general/creating_libraries.html"><span class="doc">Creating Libraries</span></a> article to |
| 1227 | learn how to do that.</p> |
| 1228 | <p>Now, to the point - there are three general rules that you must follow |
| 1229 | when creating a session driver for CodeIgniter:</p> |
| 1230 | <blockquote> |
| 1231 | <div><ul> |
| 1232 | <li><p class="first">Put your driver’s file under <strong>application/libraries/Session/drivers/</strong> |
| 1233 | and follow the naming conventions used by the Session class.</p> |
| 1234 | <p>For example, if you were to create a ‘dummy’ driver, you would have |
| 1235 | a <code class="docutils literal"><span class="pre">Session_dummy_driver</span></code> class name, that is declared in |
| 1236 | <em>application/libraries/Session/drivers/Session_dummy_driver.php</em>.</p> |
| 1237 | </li> |
| 1238 | <li><p class="first">Extend the <code class="docutils literal"><span class="pre">CI_Session_driver</span></code> class.</p> |
| 1239 | <p>This is just a basic class with a few internal helper methods. It is |
| 1240 | also extendable like any other library, if you really need to do that, |
| 1241 | but we are not going to explain how … if you’re familiar with how |
| 1242 | class extensions/overrides work in CI, then you already know how to do |
| 1243 | it. If not, well, you shouldn’t be doing it in the first place.</p> |
| 1244 | </li> |
| 1245 | <li><p class="first">Implement the <a class="reference external" href="http://php.net/sessionhandlerinterface">SessionHandlerInterface</a> interface.</p> |
| 1246 | <div class="admonition note"> |
| 1247 | <p class="first admonition-title">Note</p> |
| 1248 | <p class="last">You may notice that <code class="docutils literal"><span class="pre">SessionHandlerInterface</span></code> is provided |
| 1249 | by PHP since version 5.4.0. CodeIgniter will automatically declare |
| 1250 | the same interface if you’re running an older PHP version.</p> |
| 1251 | </div> |
| 1252 | <p>The link will explain why and how.</p> |
| 1253 | </li> |
| 1254 | </ul> |
| 1255 | </div></blockquote> |
| 1256 | <p>So, based on our ‘dummy’ driver example above, you’d end up with something |
| 1257 | like this:</p> |
| 1258 | <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="c1">// application/libraries/Session/drivers/Session_dummy_driver.php:</span> |
| 1259 | |
| 1260 | <span class="k">class</span> <span class="nc">CI_Session_dummy_driver</span> <span class="k">extends</span> <span class="nx">CI_Session_driver</span> <span class="k">implements</span> <span class="nx">SessionHandlerInterface</span> |
| 1261 | <span class="p">{</span> |
| 1262 | |
| 1263 | <span class="k">public</span> <span class="k">function</span> <span class="nf">__construct</span><span class="p">(</span><span class="o">&</span><span class="nv">$params</span><span class="p">)</span> |
| 1264 | <span class="p">{</span> |
| 1265 | <span class="c1">// DO NOT forget this</span> |
| 1266 | <span class="k">parent</span><span class="o">::</span><span class="na">__construct</span><span class="p">(</span><span class="nv">$params</span><span class="p">);</span> |
| 1267 | |
| 1268 | <span class="c1">// Configuration & other initializations</span> |
| 1269 | <span class="p">}</span> |
| 1270 | |
| 1271 | <span class="k">public</span> <span class="k">function</span> <span class="nf">open</span><span class="p">(</span><span class="nv">$save_path</span><span class="p">,</span> <span class="nv">$name</span><span class="p">)</span> |
| 1272 | <span class="p">{</span> |
| 1273 | <span class="c1">// Initialize storage mechanism (connection)</span> |
| 1274 | <span class="p">}</span> |
| 1275 | |
| 1276 | <span class="k">public</span> <span class="k">function</span> <span class="nf">read</span><span class="p">(</span><span class="nv">$session_id</span><span class="p">)</span> |
| 1277 | <span class="p">{</span> |
| 1278 | <span class="c1">// Read session data (if exists), acquire locks</span> |
| 1279 | <span class="p">}</span> |
| 1280 | |
| 1281 | <span class="k">public</span> <span class="k">function</span> <span class="nf">write</span><span class="p">(</span><span class="nv">$session_id</span><span class="p">,</span> <span class="nv">$session_data</span><span class="p">)</span> |
| 1282 | <span class="p">{</span> |
| 1283 | <span class="c1">// Create / update session data (it might not exist!)</span> |
| 1284 | <span class="p">}</span> |
| 1285 | |
| 1286 | <span class="k">public</span> <span class="k">function</span> <span class="nf">close</span><span class="p">()</span> |
| 1287 | <span class="p">{</span> |
| 1288 | <span class="c1">// Free locks, close connections / streams / etc.</span> |
| 1289 | <span class="p">}</span> |
| 1290 | |
| 1291 | <span class="k">public</span> <span class="k">function</span> <span class="nf">destroy</span><span class="p">(</span><span class="nv">$session_id</span><span class="p">)</span> |
| 1292 | <span class="p">{</span> |
| 1293 | <span class="c1">// Call close() method & destroy data for current session (order may differ)</span> |
| 1294 | <span class="p">}</span> |
| 1295 | |
| 1296 | <span class="k">public</span> <span class="k">function</span> <span class="nf">gc</span><span class="p">(</span><span class="nv">$maxlifetime</span><span class="p">)</span> |
| 1297 | <span class="p">{</span> |
| 1298 | <span class="c1">// Erase data for expired sessions</span> |
| 1299 | <span class="p">}</span> |
| 1300 | |
| 1301 | <span class="p">}</span> |
| 1302 | </pre></div> |
| 1303 | </div> |
| 1304 | <p>If you’ve done everything properly, you can now set your <em>sess_driver</em> |
| 1305 | configuration value to ‘dummy’ and use your own driver. Congratulations!</p> |
| 1306 | </div> |
| 1307 | </div> |
| 1308 | </div> |
| 1309 | <div class="section" id="class-reference"> |
| 1310 | <h2><a class="toc-backref" href="#id24">Class Reference</a><a class="headerlink" href="#class-reference" title="Permalink to this headline">¶</a></h2> |
| 1311 | <dl class="class"> |
| 1312 | <dt id="CI_Session"> |
| 1313 | <em class="property">class </em><code class="descname">CI_Session</code><a class="headerlink" href="#CI_Session" title="Permalink to this definition">¶</a></dt> |
| 1314 | <dd><dl class="method"> |
| 1315 | <dt id="CI_Session::userdata"> |
| 1316 | <code class="descname">userdata</code><span class="sig-paren">(</span><span class="optional">[</span><em>$key = NULL</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Session::userdata" title="Permalink to this definition">¶</a></dt> |
| 1317 | <dd><table class="docutils field-list" frame="void" rules="none"> |
| 1318 | <col class="field-name" /> |
| 1319 | <col class="field-body" /> |
| 1320 | <tbody valign="top"> |
| 1321 | <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> |
| 1322 | <li><strong>$key</strong> (<em>mixed</em>) – Session item key or NULL</li> |
| 1323 | </ul> |
| 1324 | </td> |
| 1325 | </tr> |
| 1326 | <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Value of the specified item key, or an array of all userdata</p> |
| 1327 | </td> |
| 1328 | </tr> |
| 1329 | <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">mixed</p> |
| 1330 | </td> |
| 1331 | </tr> |
| 1332 | </tbody> |
| 1333 | </table> |
| 1334 | <p>Gets the value for a specific <code class="docutils literal"><span class="pre">$_SESSION</span></code> item, or an |
| 1335 | array of all “userdata” items if not key was specified.</p> |
| 1336 | <div class="admonition note"> |
| 1337 | <p class="first admonition-title">Note</p> |
| 1338 | <p class="last">This is a legacy method kept only for backwards |
| 1339 | compatibility with older applications. You should |
| 1340 | directly access <code class="docutils literal"><span class="pre">$_SESSION</span></code> instead.</p> |
| 1341 | </div> |
| 1342 | </dd></dl> |
| 1343 | |
| 1344 | <dl class="method"> |
| 1345 | <dt id="CI_Session::all_userdata"> |
| 1346 | <code class="descname">all_userdata</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Session::all_userdata" title="Permalink to this definition">¶</a></dt> |
| 1347 | <dd><table class="docutils field-list" frame="void" rules="none"> |
| 1348 | <col class="field-name" /> |
| 1349 | <col class="field-body" /> |
| 1350 | <tbody valign="top"> |
| 1351 | <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">An array of all userdata</td> |
| 1352 | </tr> |
| 1353 | <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">array</td> |
| 1354 | </tr> |
| 1355 | </tbody> |
| 1356 | </table> |
| 1357 | <p>Returns an array containing all “userdata” items.</p> |
| 1358 | <div class="admonition note"> |
| 1359 | <p class="first admonition-title">Note</p> |
| 1360 | <p class="last">This method is DEPRECATED. Use <code class="docutils literal"><span class="pre">userdata()</span></code> |
| 1361 | with no parameters instead.</p> |
| 1362 | </div> |
| 1363 | </dd></dl> |
| 1364 | |
| 1365 | <dl class="method"> |
| 1366 | <dt> |
| 1367 | <code class="descname">&get_userdata()</code></dt> |
| 1368 | <dd><table class="docutils field-list" frame="void" rules="none"> |
| 1369 | <col class="field-name" /> |
| 1370 | <col class="field-body" /> |
| 1371 | <tbody valign="top"> |
| 1372 | <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">A reference to <code class="docutils literal"><span class="pre">$_SESSION</span></code></td> |
| 1373 | </tr> |
| 1374 | <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">array</td> |
| 1375 | </tr> |
| 1376 | </tbody> |
| 1377 | </table> |
| 1378 | <p>Returns a reference to the <code class="docutils literal"><span class="pre">$_SESSION</span></code> array.</p> |
| 1379 | <div class="admonition note"> |
| 1380 | <p class="first admonition-title">Note</p> |
| 1381 | <p class="last">This is a legacy method kept only for backwards |
| 1382 | compatibility with older applications.</p> |
| 1383 | </div> |
| 1384 | </dd></dl> |
| 1385 | |
| 1386 | <dl class="method"> |
| 1387 | <dt id="CI_Session::has_userdata"> |
| 1388 | <code class="descname">has_userdata</code><span class="sig-paren">(</span><em>$key</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Session::has_userdata" title="Permalink to this definition">¶</a></dt> |
| 1389 | <dd><table class="docutils field-list" frame="void" rules="none"> |
| 1390 | <col class="field-name" /> |
| 1391 | <col class="field-body" /> |
| 1392 | <tbody valign="top"> |
| 1393 | <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> |
| 1394 | <li><strong>$key</strong> (<em>string</em>) – Session item key</li> |
| 1395 | </ul> |
| 1396 | </td> |
| 1397 | </tr> |
| 1398 | <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">TRUE if the specified key exists, FALSE if not</p> |
| 1399 | </td> |
| 1400 | </tr> |
| 1401 | <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bool</p> |
| 1402 | </td> |
| 1403 | </tr> |
| 1404 | </tbody> |
| 1405 | </table> |
| 1406 | <p>Checks if an item exists in <code class="docutils literal"><span class="pre">$_SESSION</span></code>.</p> |
| 1407 | <div class="admonition note"> |
| 1408 | <p class="first admonition-title">Note</p> |
| 1409 | <p class="last">This is a legacy method kept only for backwards |
| 1410 | compatibility with older applications. It is just |
| 1411 | an alias for <code class="docutils literal"><span class="pre">isset($_SESSION[$key])</span></code> - please |
| 1412 | use that instead.</p> |
| 1413 | </div> |
| 1414 | </dd></dl> |
| 1415 | |
| 1416 | <dl class="method"> |
| 1417 | <dt id="CI_Session::set_userdata"> |
| 1418 | <code class="descname">set_userdata</code><span class="sig-paren">(</span><em>$data</em><span class="optional">[</span>, <em>$value = NULL</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Session::set_userdata" title="Permalink to this definition">¶</a></dt> |
| 1419 | <dd><table class="docutils field-list" frame="void" rules="none"> |
| 1420 | <col class="field-name" /> |
| 1421 | <col class="field-body" /> |
| 1422 | <tbody valign="top"> |
| 1423 | <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> |
| 1424 | <li><strong>$data</strong> (<em>mixed</em>) – An array of key/value pairs to set as session data, or the key for a single item</li> |
| 1425 | <li><strong>$value</strong> (<em>mixed</em>) – The value to set for a specific session item, if $data is a key</li> |
| 1426 | </ul> |
| 1427 | </td> |
| 1428 | </tr> |
| 1429 | <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">void</p> |
| 1430 | </td> |
| 1431 | </tr> |
| 1432 | </tbody> |
| 1433 | </table> |
| 1434 | <p>Assigns data to the <code class="docutils literal"><span class="pre">$_SESSION</span></code> superglobal.</p> |
| 1435 | <div class="admonition note"> |
| 1436 | <p class="first admonition-title">Note</p> |
| 1437 | <p class="last">This is a legacy method kept only for backwards |
| 1438 | compatibility with older applications.</p> |
| 1439 | </div> |
| 1440 | </dd></dl> |
| 1441 | |
| 1442 | <dl class="method"> |
| 1443 | <dt id="CI_Session::unset_userdata"> |
| 1444 | <code class="descname">unset_userdata</code><span class="sig-paren">(</span><em>$key</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Session::unset_userdata" title="Permalink to this definition">¶</a></dt> |
| 1445 | <dd><table class="docutils field-list" frame="void" rules="none"> |
| 1446 | <col class="field-name" /> |
| 1447 | <col class="field-body" /> |
| 1448 | <tbody valign="top"> |
| 1449 | <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> |
| 1450 | <li><strong>$key</strong> (<em>mixed</em>) – Key for the session data item to unset, or an array of multiple keys</li> |
| 1451 | </ul> |
| 1452 | </td> |
| 1453 | </tr> |
| 1454 | <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">void</p> |
| 1455 | </td> |
| 1456 | </tr> |
| 1457 | </tbody> |
| 1458 | </table> |
| 1459 | <p>Unsets the specified key(s) from the <code class="docutils literal"><span class="pre">$_SESSION</span></code> |
| 1460 | superglobal.</p> |
| 1461 | <div class="admonition note"> |
| 1462 | <p class="first admonition-title">Note</p> |
| 1463 | <p class="last">This is a legacy method kept only for backwards |
| 1464 | compatibility with older applications. It is just |
| 1465 | an alias for <code class="docutils literal"><span class="pre">unset($_SESSION[$key])</span></code> - please |
| 1466 | use that instead.</p> |
| 1467 | </div> |
| 1468 | </dd></dl> |
| 1469 | |
| 1470 | <dl class="method"> |
| 1471 | <dt id="CI_Session::mark_as_flash"> |
| 1472 | <code class="descname">mark_as_flash</code><span class="sig-paren">(</span><em>$key</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Session::mark_as_flash" title="Permalink to this definition">¶</a></dt> |
| 1473 | <dd><table class="docutils field-list" frame="void" rules="none"> |
| 1474 | <col class="field-name" /> |
| 1475 | <col class="field-body" /> |
| 1476 | <tbody valign="top"> |
| 1477 | <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> |
| 1478 | <li><strong>$key</strong> (<em>mixed</em>) – Key to mark as flashdata, or an array of multiple keys</li> |
| 1479 | </ul> |
| 1480 | </td> |
| 1481 | </tr> |
| 1482 | <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">TRUE on success, FALSE on failure</p> |
| 1483 | </td> |
| 1484 | </tr> |
| 1485 | <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bool</p> |
| 1486 | </td> |
| 1487 | </tr> |
| 1488 | </tbody> |
| 1489 | </table> |
| 1490 | <p>Marks a <code class="docutils literal"><span class="pre">$_SESSION</span></code> item key (or multiple ones) as |
| 1491 | “flashdata”.</p> |
| 1492 | </dd></dl> |
| 1493 | |
| 1494 | <dl class="method"> |
| 1495 | <dt id="CI_Session::get_flash_keys"> |
| 1496 | <code class="descname">get_flash_keys</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Session::get_flash_keys" title="Permalink to this definition">¶</a></dt> |
| 1497 | <dd><table class="docutils field-list" frame="void" rules="none"> |
| 1498 | <col class="field-name" /> |
| 1499 | <col class="field-body" /> |
| 1500 | <tbody valign="top"> |
| 1501 | <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Array containing the keys of all “flashdata” items.</td> |
| 1502 | </tr> |
| 1503 | <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">array</td> |
| 1504 | </tr> |
| 1505 | </tbody> |
| 1506 | </table> |
| 1507 | <p>Gets a list of all <code class="docutils literal"><span class="pre">$_SESSION</span></code> that have been marked as |
| 1508 | “flashdata”.</p> |
| 1509 | </dd></dl> |
| 1510 | |
| 1511 | <dl class="method"> |
| 1512 | <dt id="CI_Session::unmark_flash"> |
| 1513 | <code class="descname">unmark_flash</code><span class="sig-paren">(</span><em>$key</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Session::unmark_flash" title="Permalink to this definition">¶</a></dt> |
| 1514 | <dd><table class="docutils field-list" frame="void" rules="none"> |
| 1515 | <col class="field-name" /> |
| 1516 | <col class="field-body" /> |
| 1517 | <tbody valign="top"> |
| 1518 | <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> |
| 1519 | <li><strong>$key</strong> (<em>mixed</em>) – Key to be un-marked as flashdata, or an array of multiple keys</li> |
| 1520 | </ul> |
| 1521 | </td> |
| 1522 | </tr> |
| 1523 | <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">void</p> |
| 1524 | </td> |
| 1525 | </tr> |
| 1526 | </tbody> |
| 1527 | </table> |
| 1528 | <p>Unmarks a <code class="docutils literal"><span class="pre">$_SESSION</span></code> item key (or multiple ones) as |
| 1529 | “flashdata”.</p> |
| 1530 | </dd></dl> |
| 1531 | |
| 1532 | <dl class="method"> |
| 1533 | <dt id="CI_Session::flashdata"> |
| 1534 | <code class="descname">flashdata</code><span class="sig-paren">(</span><span class="optional">[</span><em>$key = NULL</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Session::flashdata" title="Permalink to this definition">¶</a></dt> |
| 1535 | <dd><table class="docutils field-list" frame="void" rules="none"> |
| 1536 | <col class="field-name" /> |
| 1537 | <col class="field-body" /> |
| 1538 | <tbody valign="top"> |
| 1539 | <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> |
| 1540 | <li><strong>$key</strong> (<em>mixed</em>) – Flashdata item key or NULL</li> |
| 1541 | </ul> |
| 1542 | </td> |
| 1543 | </tr> |
| 1544 | <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Value of the specified item key, or an array of all flashdata</p> |
| 1545 | </td> |
| 1546 | </tr> |
| 1547 | <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">mixed</p> |
| 1548 | </td> |
| 1549 | </tr> |
| 1550 | </tbody> |
| 1551 | </table> |
| 1552 | <p>Gets the value for a specific <code class="docutils literal"><span class="pre">$_SESSION</span></code> item that has |
| 1553 | been marked as “flashdata”, or an array of all “flashdata” |
| 1554 | items if no key was specified.</p> |
| 1555 | <div class="admonition note"> |
| 1556 | <p class="first admonition-title">Note</p> |
| 1557 | <p class="last">This is a legacy method kept only for backwards |
| 1558 | compatibility with older applications. You should |
| 1559 | directly access <code class="docutils literal"><span class="pre">$_SESSION</span></code> instead.</p> |
| 1560 | </div> |
| 1561 | </dd></dl> |
| 1562 | |
| 1563 | <dl class="method"> |
| 1564 | <dt id="CI_Session::keep_flashdata"> |
| 1565 | <code class="descname">keep_flashdata</code><span class="sig-paren">(</span><em>$key</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Session::keep_flashdata" title="Permalink to this definition">¶</a></dt> |
| 1566 | <dd><table class="docutils field-list" frame="void" rules="none"> |
| 1567 | <col class="field-name" /> |
| 1568 | <col class="field-body" /> |
| 1569 | <tbody valign="top"> |
| 1570 | <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> |
| 1571 | <li><strong>$key</strong> (<em>mixed</em>) – Flashdata key to keep, or an array of multiple keys</li> |
| 1572 | </ul> |
| 1573 | </td> |
| 1574 | </tr> |
| 1575 | <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">TRUE on success, FALSE on failure</p> |
| 1576 | </td> |
| 1577 | </tr> |
| 1578 | <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bool</p> |
| 1579 | </td> |
| 1580 | </tr> |
| 1581 | </tbody> |
| 1582 | </table> |
| 1583 | <p>Retains the specified session data key(s) as “flashdata” |
| 1584 | through the next request.</p> |
| 1585 | <div class="admonition note"> |
| 1586 | <p class="first admonition-title">Note</p> |
| 1587 | <p class="last">This is a legacy method kept only for backwards |
| 1588 | compatibility with older applications. It is just |
| 1589 | an alias for the <code class="docutils literal"><span class="pre">mark_as_flash()</span></code> method.</p> |
| 1590 | </div> |
| 1591 | </dd></dl> |
| 1592 | |
| 1593 | <dl class="method"> |
| 1594 | <dt id="CI_Session::set_flashdata"> |
| 1595 | <code class="descname">set_flashdata</code><span class="sig-paren">(</span><em>$data</em><span class="optional">[</span>, <em>$value = NULL</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Session::set_flashdata" title="Permalink to this definition">¶</a></dt> |
| 1596 | <dd><table class="docutils field-list" frame="void" rules="none"> |
| 1597 | <col class="field-name" /> |
| 1598 | <col class="field-body" /> |
| 1599 | <tbody valign="top"> |
| 1600 | <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> |
| 1601 | <li><strong>$data</strong> (<em>mixed</em>) – An array of key/value pairs to set as flashdata, or the key for a single item</li> |
| 1602 | <li><strong>$value</strong> (<em>mixed</em>) – The value to set for a specific session item, if $data is a key</li> |
| 1603 | </ul> |
| 1604 | </td> |
| 1605 | </tr> |
| 1606 | <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">void</p> |
| 1607 | </td> |
| 1608 | </tr> |
| 1609 | </tbody> |
| 1610 | </table> |
| 1611 | <p>Assigns data to the <code class="docutils literal"><span class="pre">$_SESSION</span></code> superglobal and marks it |
| 1612 | as “flashdata”.</p> |
| 1613 | <div class="admonition note"> |
| 1614 | <p class="first admonition-title">Note</p> |
| 1615 | <p class="last">This is a legacy method kept only for backwards |
| 1616 | compatibility with older applications.</p> |
| 1617 | </div> |
| 1618 | </dd></dl> |
| 1619 | |
| 1620 | <dl class="method"> |
| 1621 | <dt id="CI_Session::mark_as_temp"> |
| 1622 | <code class="descname">mark_as_temp</code><span class="sig-paren">(</span><em>$key</em><span class="optional">[</span>, <em>$ttl = 300</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Session::mark_as_temp" title="Permalink to this definition">¶</a></dt> |
| 1623 | <dd><table class="docutils field-list" frame="void" rules="none"> |
| 1624 | <col class="field-name" /> |
| 1625 | <col class="field-body" /> |
| 1626 | <tbody valign="top"> |
| 1627 | <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> |
| 1628 | <li><strong>$key</strong> (<em>mixed</em>) – Key to mark as tempdata, or an array of multiple keys</li> |
| 1629 | <li><strong>$ttl</strong> (<em>int</em>) – Time-to-live value for the tempdata, in seconds</li> |
| 1630 | </ul> |
| 1631 | </td> |
| 1632 | </tr> |
| 1633 | <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">TRUE on success, FALSE on failure</p> |
| 1634 | </td> |
| 1635 | </tr> |
| 1636 | <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bool</p> |
| 1637 | </td> |
| 1638 | </tr> |
| 1639 | </tbody> |
| 1640 | </table> |
| 1641 | <p>Marks a <code class="docutils literal"><span class="pre">$_SESSION</span></code> item key (or multiple ones) as |
| 1642 | “tempdata”.</p> |
| 1643 | </dd></dl> |
| 1644 | |
| 1645 | <dl class="method"> |
| 1646 | <dt id="CI_Session::get_temp_keys"> |
| 1647 | <code class="descname">get_temp_keys</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Session::get_temp_keys" title="Permalink to this definition">¶</a></dt> |
| 1648 | <dd><table class="docutils field-list" frame="void" rules="none"> |
| 1649 | <col class="field-name" /> |
| 1650 | <col class="field-body" /> |
| 1651 | <tbody valign="top"> |
| 1652 | <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">Array containing the keys of all “tempdata” items.</td> |
| 1653 | </tr> |
| 1654 | <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">array</td> |
| 1655 | </tr> |
| 1656 | </tbody> |
| 1657 | </table> |
| 1658 | <p>Gets a list of all <code class="docutils literal"><span class="pre">$_SESSION</span></code> that have been marked as |
| 1659 | “tempdata”.</p> |
| 1660 | </dd></dl> |
| 1661 | |
| 1662 | <dl class="method"> |
| 1663 | <dt id="CI_Session::unmark_temp"> |
| 1664 | <code class="descname">unmark_temp</code><span class="sig-paren">(</span><em>$key</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Session::unmark_temp" title="Permalink to this definition">¶</a></dt> |
| 1665 | <dd><table class="docutils field-list" frame="void" rules="none"> |
| 1666 | <col class="field-name" /> |
| 1667 | <col class="field-body" /> |
| 1668 | <tbody valign="top"> |
| 1669 | <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> |
| 1670 | <li><strong>$key</strong> (<em>mixed</em>) – Key to be un-marked as tempdata, or an array of multiple keys</li> |
| 1671 | </ul> |
| 1672 | </td> |
| 1673 | </tr> |
| 1674 | <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">void</p> |
| 1675 | </td> |
| 1676 | </tr> |
| 1677 | </tbody> |
| 1678 | </table> |
| 1679 | <p>Unmarks a <code class="docutils literal"><span class="pre">$_SESSION</span></code> item key (or multiple ones) as |
| 1680 | “tempdata”.</p> |
| 1681 | </dd></dl> |
| 1682 | |
| 1683 | <dl class="method"> |
| 1684 | <dt id="CI_Session::tempdata"> |
| 1685 | <code class="descname">tempdata</code><span class="sig-paren">(</span><span class="optional">[</span><em>$key = NULL</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Session::tempdata" title="Permalink to this definition">¶</a></dt> |
| 1686 | <dd><table class="docutils field-list" frame="void" rules="none"> |
| 1687 | <col class="field-name" /> |
| 1688 | <col class="field-body" /> |
| 1689 | <tbody valign="top"> |
| 1690 | <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> |
| 1691 | <li><strong>$key</strong> (<em>mixed</em>) – Tempdata item key or NULL</li> |
| 1692 | </ul> |
| 1693 | </td> |
| 1694 | </tr> |
| 1695 | <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Value of the specified item key, or an array of all tempdata</p> |
| 1696 | </td> |
| 1697 | </tr> |
| 1698 | <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">mixed</p> |
| 1699 | </td> |
| 1700 | </tr> |
| 1701 | </tbody> |
| 1702 | </table> |
| 1703 | <p>Gets the value for a specific <code class="docutils literal"><span class="pre">$_SESSION</span></code> item that has |
| 1704 | been marked as “tempdata”, or an array of all “tempdata” |
| 1705 | items if no key was specified.</p> |
| 1706 | <div class="admonition note"> |
| 1707 | <p class="first admonition-title">Note</p> |
| 1708 | <p class="last">This is a legacy method kept only for backwards |
| 1709 | compatibility with older applications. You should |
| 1710 | directly access <code class="docutils literal"><span class="pre">$_SESSION</span></code> instead.</p> |
| 1711 | </div> |
| 1712 | </dd></dl> |
| 1713 | |
| 1714 | <dl class="method"> |
| 1715 | <dt id="CI_Session::set_tempdata"> |
| 1716 | <code class="descname">set_tempdata</code><span class="sig-paren">(</span><em>$data</em><span class="optional">[</span>, <em>$value = NULL</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Session::set_tempdata" title="Permalink to this definition">¶</a></dt> |
| 1717 | <dd><table class="docutils field-list" frame="void" rules="none"> |
| 1718 | <col class="field-name" /> |
| 1719 | <col class="field-body" /> |
| 1720 | <tbody valign="top"> |
| 1721 | <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> |
| 1722 | <li><strong>$data</strong> (<em>mixed</em>) – An array of key/value pairs to set as tempdata, or the key for a single item</li> |
| 1723 | <li><strong>$value</strong> (<em>mixed</em>) – The value to set for a specific session item, if $data is a key</li> |
| 1724 | <li><strong>$ttl</strong> (<em>int</em>) – Time-to-live value for the tempdata item(s), in seconds</li> |
| 1725 | </ul> |
| 1726 | </td> |
| 1727 | </tr> |
| 1728 | <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">void</p> |
| 1729 | </td> |
| 1730 | </tr> |
| 1731 | </tbody> |
| 1732 | </table> |
| 1733 | <p>Assigns data to the <code class="docutils literal"><span class="pre">$_SESSION</span></code> superglobal and marks it |
| 1734 | as “tempdata”.</p> |
| 1735 | <div class="admonition note"> |
| 1736 | <p class="first admonition-title">Note</p> |
| 1737 | <p class="last">This is a legacy method kept only for backwards |
| 1738 | compatibility with older applications.</p> |
| 1739 | </div> |
| 1740 | </dd></dl> |
| 1741 | |
| 1742 | <dl class="method"> |
| 1743 | <dt id="CI_Session::sess_regenerate"> |
| 1744 | <code class="descname">sess_regenerate</code><span class="sig-paren">(</span><span class="optional">[</span><em>$destroy = FALSE</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Session::sess_regenerate" title="Permalink to this definition">¶</a></dt> |
| 1745 | <dd><table class="docutils field-list" frame="void" rules="none"> |
| 1746 | <col class="field-name" /> |
| 1747 | <col class="field-body" /> |
| 1748 | <tbody valign="top"> |
| 1749 | <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> |
| 1750 | <li><strong>$destroy</strong> (<em>bool</em>) – Whether to destroy session data</li> |
| 1751 | </ul> |
| 1752 | </td> |
| 1753 | </tr> |
| 1754 | <tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">void</p> |
| 1755 | </td> |
| 1756 | </tr> |
| 1757 | </tbody> |
| 1758 | </table> |
| 1759 | <p>Regenerate session ID, optionally destroying the current |
| 1760 | session’s data.</p> |
| 1761 | <div class="admonition note"> |
| 1762 | <p class="first admonition-title">Note</p> |
| 1763 | <p class="last">This method is just an alias for PHP’s native |
| 1764 | <a class="reference external" href="http://php.net/session_regenerate_id">session_regenerate_id()</a> function.</p> |
| 1765 | </div> |
| 1766 | </dd></dl> |
| 1767 | |
| 1768 | <dl class="method"> |
| 1769 | <dt id="CI_Session::sess_destroy"> |
| 1770 | <code class="descname">sess_destroy</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#CI_Session::sess_destroy" title="Permalink to this definition">¶</a></dt> |
| 1771 | <dd><table class="docutils field-list" frame="void" rules="none"> |
| 1772 | <col class="field-name" /> |
| 1773 | <col class="field-body" /> |
| 1774 | <tbody valign="top"> |
| 1775 | <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">void</td> |
| 1776 | </tr> |
| 1777 | </tbody> |
| 1778 | </table> |
| 1779 | <p>Destroys the current session.</p> |
| 1780 | <div class="admonition note"> |
| 1781 | <p class="first admonition-title">Note</p> |
| 1782 | <p class="last">This must be the <em>last</em> session-related function |
| 1783 | that you call. All session data will be lost after |
| 1784 | you do that.</p> |
| 1785 | </div> |
| 1786 | <div class="admonition note"> |
| 1787 | <p class="first admonition-title">Note</p> |
| 1788 | <p class="last">This method is just an alias for PHP’s native |
| 1789 | <a class="reference external" href="http://php.net/session_destroy">session_destroy()</a> function.</p> |
| 1790 | </div> |
| 1791 | </dd></dl> |
| 1792 | |
| 1793 | <dl class="method"> |
| 1794 | <dt id="CI_Session::__get"> |
| 1795 | <code class="descname">__get</code><span class="sig-paren">(</span><em>$key</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Session::__get" title="Permalink to this definition">¶</a></dt> |
| 1796 | <dd><table class="docutils field-list" frame="void" rules="none"> |
| 1797 | <col class="field-name" /> |
| 1798 | <col class="field-body" /> |
| 1799 | <tbody valign="top"> |
| 1800 | <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> |
| 1801 | <li><strong>$key</strong> (<em>string</em>) – Session item key</li> |
| 1802 | </ul> |
| 1803 | </td> |
| 1804 | </tr> |
| 1805 | <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">The requested session data item, or NULL if it doesn’t exist</p> |
| 1806 | </td> |
| 1807 | </tr> |
| 1808 | <tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">mixed</p> |
| 1809 | </td> |
| 1810 | </tr> |
| 1811 | </tbody> |
| 1812 | </table> |
| 1813 | <p>A magic method that allows you to use |
| 1814 | <code class="docutils literal"><span class="pre">$this->session->item</span></code> instead of <code class="docutils literal"><span class="pre">$_SESSION['item']</span></code>, |
| 1815 | if that’s what you prefer.</p> |
| 1816 | <p>It will also return the session ID by calling |
| 1817 | <code class="docutils literal"><span class="pre">session_id()</span></code> if you try to access |
| 1818 | <code class="docutils literal"><span class="pre">$this->session->session_id</span></code>.</p> |
| 1819 | </dd></dl> |
| 1820 | |
| 1821 | <dl class="method"> |
| 1822 | <dt id="CI_Session::__set"> |
| 1823 | <code class="descname">__set</code><span class="sig-paren">(</span><em>$key</em>, <em>$value</em><span class="sig-paren">)</span><a class="headerlink" href="#CI_Session::__set" title="Permalink to this definition">¶</a></dt> |
| 1824 | <dd><table class="docutils field-list" frame="void" rules="none"> |
| 1825 | <col class="field-name" /> |
| 1826 | <col class="field-body" /> |
| 1827 | <tbody valign="top"> |
| 1828 | <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> |
| 1829 | <li><strong>$key</strong> (<em>string</em>) – Session item key</li> |
| 1830 | <li><strong>$value</strong> (<em>mixed</em>) – Value to assign to the session item key</li> |
| 1831 | </ul> |
| 1832 | </td> |
| 1833 | </tr> |
| 1834 | <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">void</p> |
| 1835 | </td> |
| 1836 | </tr> |
| 1837 | </tbody> |
| 1838 | </table> |
| 1839 | <p>A magic method that allows you to assign items to |
| 1840 | <code class="docutils literal"><span class="pre">$_SESSION</span></code> by accessing them as <code class="docutils literal"><span class="pre">$this->session</span></code> |
| 1841 | properties:</p> |
| 1842 | <div class="highlight-ci"><div class="highlight"><pre><span></span><span class="nv">$this</span><span class="o">-></span><span class="na">session</span><span class="o">-></span><span class="na">foo</span> <span class="o">=</span> <span class="s1">'bar'</span><span class="p">;</span> |
| 1843 | |
| 1844 | <span class="c1">// Results in:</span> |
| 1845 | <span class="c1">// $_SESSION['foo'] = 'bar';</span> |
| 1846 | </pre></div> |
| 1847 | </div> |
| 1848 | </dd></dl> |
| 1849 | |
| 1850 | </dd></dl> |
| 1851 | |
| 1852 | </div> |
| 1853 | </div> |
| 1854 | |
| 1855 | |
| 1856 | </div> |
| 1857 | <footer> |
| 1858 | |
| 1859 | <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> |
| 1860 | |
| 1861 | <a href="table.html" class="btn btn-neutral float-right" title="HTML Table Class">Next <span class="fa fa-arrow-circle-right"></span></a> |
| 1862 | |
| 1863 | |
| 1864 | <a href="security.html" class="btn btn-neutral" title="Security Class"><span class="fa fa-arrow-circle-left"></span> Previous</a> |
| 1865 | |
| 1866 | </div> |
| 1867 | |
| 1868 | |
| 1869 | <hr/> |
| 1870 | |
| 1871 | <div role="contentinfo"> |
| 1872 | <p> |
| 1873 | © Copyright 2014 - 2019, British Columbia Institute of Technology. |
| 1874 | Last updated on Jan 16, 2019. |
| 1875 | </p> |
| 1876 | </div> |
| 1877 | |
| 1878 | Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. |
| 1879 | |
| 1880 | </footer> |
| 1881 | </div> |
| 1882 | </div> |
| 1883 | |
| 1884 | </section> |
| 1885 | |
| 1886 | </div> |
| 1887 | |
| 1888 | |
| 1889 | |
| 1890 | |
| 1891 | |
| 1892 | <script type="text/javascript"> |
| 1893 | var DOCUMENTATION_OPTIONS = { |
| 1894 | URL_ROOT:'../', |
| 1895 | VERSION:'3.1.10', |
| 1896 | COLLAPSE_INDEX:false, |
| 1897 | FILE_SUFFIX:'.html', |
| 1898 | HAS_SOURCE: false |
| 1899 | }; |
| 1900 | </script> |
| 1901 | <script type="text/javascript" src="../_static/jquery.js"></script> |
| 1902 | <script type="text/javascript" src="../_static/underscore.js"></script> |
| 1903 | <script type="text/javascript" src="../_static/doctools.js"></script> |
| 1904 | |
| 1905 | |
| 1906 | |
| 1907 | |
| 1908 | |
| 1909 | <script type="text/javascript" src="../_static/js/theme.js"></script> |
| 1910 | |
| 1911 | |
| 1912 | |
| 1913 | |
| 1914 | <script type="text/javascript"> |
| 1915 | jQuery(function () { |
| 1916 | SphinxRtdTheme.StickyNav.enable(); |
| 1917 | }); |
| 1918 | </script> |
| 1919 | |
| 1920 | |
| 1921 | </body> |
| 1922 | </html> |