{"id":2089,"date":"2019-08-13T13:39:33","date_gmt":"2019-08-13T12:39:33","guid":{"rendered":"https:\/\/ibex.tech\/cloud\/?p=2089"},"modified":"2025-10-19T10:10:07","modified_gmt":"2025-10-19T09:10:07","slug":"_session-in-wordpress","status":"publish","type":"post","link":"https:\/\/ibex.tech\/cloud\/php\/sessions\/_session-in-wordpress","title":{"rendered":"$_SESSION in wordpress"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">Enabling $_SESSION<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/**************************************************\n\/\/**************************************************\n\/\/********** ENABLE SESSIONS IN WORDPRESS **********\n\/\/**************************************************\n\/\/**************************************************\nadd_action('init', 'myStartSession', 1);  \/\/&lt;&lt;&lt;&lt;Change myStartSession to a unique name\nadd_action('wp_logout', 'myEndSession');  \/\/&lt;&lt;&lt;&lt;Change myEndSession to a unique name\nadd_action('wp_login', 'myEndSession');   \/\/&lt;&lt;&lt;&lt;Change myEndSession to a unique name (don't use if you want to track session vaues as someone logs in!)\n\nfunction myStartSession()\n{\n  if(!session_id())\n  {\n    session_start();\n  }\n}\n\nfunction myEndSession()\n{\n  \/\/session_destroy();    \/\/You do not have to call session_destroy() from usual code. Cleanup $_SESSION array rather than destroying session data.\n  \n  \/\/Unset all of the session variables\n  $_SESSION = array();\n}<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Using $_SESSION<\/h4>\n\n\n\n<p>See here.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Enabling $_SESSION Using $_SESSION See here.<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[79,173],"tags":[],"class_list":["post-2089","post","type-post","status-publish","format-standard","hentry","category-sessions","category-sessions-wordpress"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/2089","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/comments?post=2089"}],"version-history":[{"count":4,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/2089\/revisions"}],"predecessor-version":[{"id":5164,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/posts\/2089\/revisions\/5164"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/media?parent=2089"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/categories?post=2089"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/cloud\/wp-json\/wp\/v2\/tags?post=2089"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}