<?php session_start();

$page_flag=1;

	?>
	<?php
	  //initialize the diffrent search field when  starting from home page
	 if($page_flag=='1')
	 {                                   
              session_register('location')='';  
			  session_register('job')='';
			  session_register('key_wd')='';
	          session_register('pagenum')=1;
	 }

	?>
	I got a message that:

Fatal error: Can't use function return value in write context in line 17 and line 17 is session_register('location')=''; ........can you help me to find out the correction

    I could be wrong, but I don't think you can assign values using session_register() function. You can however, set the variable to whatever value desired and then register the variable.

    $location = '';
    session_register('location');
    

      But why use session_register at all? In the manual it says:

      If you want your script to work regardless of register_globals, you need to instead use the $SESSION array as $SESSION entries are automatically registered. If your script uses session_register(), it will not work in environments where the PHP directive register_globals is disabled.

      Basically it means that it is better to use $_SESSION.

        Write a Reply...