m0v0nage Posted February 5, 2010 Share Posted February 5, 2010 My website is made up of html files. Recently I realized i needed php. I edited the .htaccess file so that it looks like this: AddType application/x-httpd-php .htm .html This allowed me to execute php on any html page. But one thing I am having trouble with is accessing Session information. I do this on an html page: $name = $_SESSION['Name']; with the session_start() at the top (I know I did that correctly). It can't seem to find the name. I do the same on a .php page, and it works. But why can't an html page access the Session variables? It can echo things and run other php functions, but why not the SESSION info. Quote Link to comment https://forums.phpfreaks.com/topic/191008-accessing-_session-variables-on-html/ Share on other sites More sharing options...
oni-kun Posted February 5, 2010 Share Posted February 5, 2010 Why not try a debugging test? one.html: <?php session_start(); $_SESSION['Name'] = 'foo'; header('Location: two.html'); ?> two.html <?php session_start(); echo '<pre>'; print_r($_SESSION); ?> Does it return anything? Does the PHP code turn up in the source? Quote Link to comment https://forums.phpfreaks.com/topic/191008-accessing-_session-variables-on-html/#findComment-1007236 Share on other sites More sharing options...
PFMaBiSmAd Posted February 5, 2010 Share Posted February 5, 2010 For debugging purposes, add the following two lines of code immediately after your first opening <?php tag on the page - ini_set("display_errors", "1"); error_reporting(E_ALL); Quote Link to comment https://forums.phpfreaks.com/topic/191008-accessing-_session-variables-on-html/#findComment-1007339 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.