Adding session variable and/or cookie based on user-selected input

You can definitly use PHP session variables. Follow this blog post (“Listing 3”) for the best way to enable PHP sessions in WordPress. Namely, you need to use this code in your plugin or in your theme’s funtions.php:

add_action( 'init', 'session_start', 0 );

After that you can use basic session variables to set the country when the user selects it, and subsequently access the country that the user has selected.

Good Luck!

Leave a Comment