php - Why isn't $_SESSION data being preserved across pages? -


why $_session data not being preserved across pages? can access $_session data on , on over same page, not page other 1 set on.

index.php (set attempt):

<?php     session_start();     $_session['test'] = '1'; ?> <!doctype html> <html lang="en">     <head>         <title>title</title>     </head>     <body>         <h1>heading</h1>         <a href="pagetwo.php">page two</a>     </body> </html> 

pagetwo.php (get attempt):

<?php     session_start(); ?> <!doctype html> <html lang="en-us">     <head>         <title>title</title>     </head>     <body>         <?             echo $_session['test'];         ?>     </body> </html> 

problem in php tag.

your tag should be

<?php    echo $_session['test']; ?> 

Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

android - CollapsingToolbarLayout: position the ExpandedText programmatically -

Listeners to visualise results of load test in JMeter -