Session.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. // This file is part of GNU social - https://www.gnu.org/software/social
  3. //
  4. // GNU social is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU Affero General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // GNU social is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU Affero General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU Affero General Public License
  15. // along with GNU social. If not, see <http://www.gnu.org/licenses/>.
  16. /**
  17. * Table Definition for session
  18. *
  19. * @package GNUsocial
  20. * @author Evan Prodromou
  21. * @author Brion Vibber
  22. * @author Mikael Nordfeldth
  23. * @author Sorokin Alexei
  24. * @author Diogo Cordeiro <diogo@fc.up.pt>
  25. * @copyright 2019 Free Software Foundation, Inc http://www.fsf.org
  26. * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
  27. */
  28. defined('GNUSOCIAL') || die();
  29. require_once INSTALLDIR . '/classes/Memcached_DataObject.php';
  30. /**
  31. * Superclass representing a saved session as it exists in the database.
  32. *
  33. * @copyright 2019 Free Software Foundation, Inc http://www.fsf.org
  34. * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
  35. */
  36. class Session extends Managed_DataObject
  37. {
  38. ###START_AUTOCODE
  39. /* the code below is auto generated do not remove the above tag */
  40. public $__table = 'session'; // table name
  41. public $id; // varchar(32) primary_key not_null
  42. public $session_data; // text()
  43. public $created; // datetime() not_null
  44. public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
  45. /* the code above is auto generated do not remove the tag below */
  46. ###END_AUTOCODE
  47. /**
  48. * Returns an array describing how the session is stored in the database.
  49. *
  50. * @return array
  51. */
  52. public static function schemaDef()
  53. {
  54. return [
  55. 'fields' => [
  56. 'id' => ['type' => 'varchar', 'length' => 32, 'not null' => true, 'description' => 'session ID'],
  57. 'session_data' => ['type' => 'text', 'description' => 'session data'],
  58. 'created' => ['type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'],
  59. 'modified' => ['type' => 'timestamp', 'not null' => true, 'description' => 'date this record was modified'],
  60. ],
  61. 'primary key' => ['id'],
  62. 'indexes' => [
  63. 'session_modified_idx' => ['modified'],
  64. ],
  65. ];
  66. }
  67. /**
  68. * New code should NOT call this function.
  69. * Dummy function for backwards compatibility with older plugins like Qvitter.
  70. * Stuff to do before the request teardown.
  71. *
  72. * @return void
  73. */
  74. public static function cleanup()
  75. {
  76. session_write_close();
  77. }
  78. }