{"id":793,"date":"2014-01-10T11:40:59","date_gmt":"2014-01-10T10:40:59","guid":{"rendered":"http:\/\/www.symablog.de\/blog\/?p=793"},"modified":"2014-05-14T10:29:44","modified_gmt":"2014-05-14T09:29:44","slug":"php-aktuelle-session-variablen-anzeigen","status":"publish","type":"post","link":"https:\/\/www.symablog.de\/blog\/php-aktuelle-session-variablen-anzeigen\/","title":{"rendered":"PHP: aktuelle Session Variablen anzeigen"},"content":{"rendered":"<p>Um die Session Variablen der aktuellen Sitzung darzustellen, wird eine Schleife \u00fcber das Array @_SESSION gefahren, mit allen Schl\u00fcsseln (Keys).<br \/>\nIm PHP-Programmcode sieht das dann so aus:<\/p>\n<pre lang=\"PHP\"><?php\r\n      echo '<table border=1>';\r\n      echo '<tr><td><b>KEY<\/b><\/td><td><b>VALUE<\/b><\/td><\/tr>';\r\n      foreach ($_SESSION as $key =>$value) \r\n      {\r\n          echo '<tr><td>'.$key.'<\/td>';\r\n          echo '<td>'.$value.'<\/td><\/tr>';\r\n      }\r\n      echo '<\/table>';\r\n?><\/pre>\n<p>Als Beispiel um eine Session zu starten und Variablen zu setzen, nehmen wir eine WordPress Installation (w\u00e4re sonst zu einfach \ud83d\ude42 ). In der wp-config.php folgenden Block einf\u00fcgen:<\/p>\n<pre lang=\"PHP\">\/**\r\n* SESSION - Start Session if not started\r\n*\/\r\nif (!session_id())\r\n    session_start();\r\n    $_SESSION['tonium_session_id'] = session_id();\r\n\r\n    $ip = getenv('REMOTE_ADDR');\r\n    $_SESSION['remote_ip'] = $ip;\r\n\r\n    $host = gethostbyaddr($ip);\r\n    $_SESSION['remote_host'] = $host;\r\n\r\n    $_SESSION['f_count']++;\r\n...<\/pre>\n<p>und so sieht es dann aus:<\/p>\n<div>\n<table border=\"0\">\n<tbody>\n<tr>\n<td width=\"160\">    <b>KEY<\/b><\/td>\n<td>    <b>VALUE<\/b><\/td>\n<\/tr>\n<tr>\n<td>    tonium_session_id<\/td>\n<td>    7t02coobg6khm97hriqi0c0817<\/td>\n<\/tr>\n<tr>\n<td>    remote_ip<\/td>\n<td>    91.19.110.190<\/td>\n<\/tr>\n<tr>\n<td>    remote_host<\/td>\n<td>    p5B136EBG.dip0.t-ipconnect.de<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Testdemo unter <a href=\"http:\/\/0815.ws\/l43Hu\" title=\"Demo Test Session Variables\" target=\"_blank\">www.Tonium.de<\/a>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Um die Session Variablen der aktuellen Sitzung darzustellen, wird eine Schleife \u00fcber das Array @_SESSION gefahren, mit allen Schl\u00fcsseln (Keys). Im PHP-Programmcode sieht das dann so aus: Als Beispiel um eine Session zu starten und Variablen zu setzen, nehmen wir &hellip; <a class=\"more-link\" href=\"https:\/\/www.symablog.de\/blog\/php-aktuelle-session-variablen-anzeigen\/\">Weiterlesen <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[135],"tags":[136,198,137],"class_list":["post-793","post","type-post","status-publish","format-standard","hentry","category-php","tag-_session","tag-php","tag-session-variables"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p37Rzq-cN","_links":{"self":[{"href":"https:\/\/www.symablog.de\/blog\/wp-json\/wp\/v2\/posts\/793"}],"collection":[{"href":"https:\/\/www.symablog.de\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.symablog.de\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.symablog.de\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.symablog.de\/blog\/wp-json\/wp\/v2\/comments?post=793"}],"version-history":[{"count":16,"href":"https:\/\/www.symablog.de\/blog\/wp-json\/wp\/v2\/posts\/793\/revisions"}],"predecessor-version":[{"id":861,"href":"https:\/\/www.symablog.de\/blog\/wp-json\/wp\/v2\/posts\/793\/revisions\/861"}],"wp:attachment":[{"href":"https:\/\/www.symablog.de\/blog\/wp-json\/wp\/v2\/media?parent=793"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.symablog.de\/blog\/wp-json\/wp\/v2\/categories?post=793"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.symablog.de\/blog\/wp-json\/wp\/v2\/tags?post=793"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}