Jump to content

[SOLVED] $_SESSION?


venturemc

Recommended Posts

I'm trying to use the suoer global $_SESSION variable to store data between pages. It doesn't seem to be working. In my debugger (Eclipse) I can see my values being stored, but the debugger won't carry on to the next page after executing an action, so I can;t watch it as the pages "change".

 

When I run the page on a browser, I get nothing out of the $_SESSION variable.

 

Example of use:

<?php session_start();
$_SESSION['action'] = 'submit_se';
........

submit button named 'submit_se' takes me to an 'action' script:

  <?php  include_once '.......php';

// for debugging
var_dump($_SESSION);

switch ($_SESSION['action']){
case 'submit_se':
bld_qry();
break;
case 'submit_cri':
get_qry_results();
break;
case 'add_row':
add_cri_row();
break;
default:
echo '->unrecognized action<-'; 
}
?>

I know I'm getting to the 'action' script. The var_dump is producing a 'null' and I get my default error message.

 

I've tried using the session_start() command again (don't think I need to?) at the top of the 'action' script and it made no difference.

 

What am I missing here?

Link to comment
https://forums.phpfreaks.com/topic/175288-solved-_session/
Share on other sites

Each page that sets or references a $_SESSION variable needs a session_start() statement.

 

Based on the space before the <?php tag in the code posted for action.php, you likely have a header error that prevented the session from starting. Are you developing php code and debugging php code on a system with error_reporting set to E_ALL and display_errors set to ON in your php.ini so that php would help you? Stop and start your web server to get any change made to php.ini to take effect and use a phpinfo() statement to confirm that the settings were actually changed in case the php.ini that you are changing is not the one that php is using.

Link to comment
https://forums.phpfreaks.com/topic/175288-solved-_session/#findComment-923840
Share on other sites

Well, no, actually that "space" is where I removed the session_start() line. (That script is a complete cut/paste with the include statement edited.)

 

Curiously, I retyped it back in and now it seems to work! I must have just not reloaded it onto the server aftrer editing (lot's of pages bouncing around).

 

Thanks much!

Link to comment
https://forums.phpfreaks.com/topic/175288-solved-_session/#findComment-923844
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.