html - PHP Session not working, cannot bring value over the next page -


need session, not sure whats going wrong.

page 1

    <?php session_start()?>     <html>       <head>       </head>         <body>           <?php             $_session['name'] = 'john';             print_r ($_session);           ?>         </body>     </html> 

page 2

    <?php session_start()?>     <html>       <head>       </head>         <body>           <?php              print_r ($_session);           ?>         </body>     </html> 

page 1 result array ( [name] => john )

page 2 result array ( )

i did have session_start(); @ both pages
tried ie , firefox didnt work
advices please , :)

as stated lanzz, need either call session_start() in both pages or set session.auto_start 1 on yout php.ini.

after edit

you seem have spaces before php opening tag (<?php). must first thing evaluated. if isn't, can't send headers session data, , not work. should emit warning, have them disabled. fix it, write code follows.

<?php session_start()?> <html>   <head>   </head>     <body>       <?php         $_session['name'] = 'john';         print_r ($_session);       ?>     </body> </html> 

if still don't work, you'll have file utf-8 with bom, should disable bom. how depends on editor.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -