ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Store & retrieve variables on the fly (trying to set country for a visitor sitewide with ip2nation)

July 03, 2012 5:48am

Subscribe [2]
  • #1 / Jul 03, 2012 5:48am

    photek

    15 posts

    Hi,

    I’m trying to set country for a visitor automatically, and keep it sitewide in order to show correct currencies and links (all in same language tho).

    The idea is to detect country with ip2nation, set a variable with the country name and then use conditionals in some places to show different currencies & links depending on the country variable. Ideally the variable has to be kept for all pages for faster load times.

    How can i do that? haven’t found how to do it on docs.

    Regards,

  • #2 / Jul 03, 2012 5:56am

    mark186282

    290 posts

    how about using cookies?

    http://devot-ee.com/add-ons/cookie-plus

    check to see if the cookie is set (if it is, use it as a variable to update currency, language, etc)

    if it isn’t set, use ip2nation to set the language and country

  • #3 / Jul 03, 2012 6:13am

    photek

    15 posts

    I saw this plugin, session_variables and variables plugin (all in devotee), but all of these 3 seems to have problems with if statements from reading the comments and archived forums.

  • #4 / Jul 03, 2012 6:22am

    mark186282

    290 posts

    a less preferred way to deal with that would be to check, set and retrieve the cookie(s) in PHP, and use the PHP rendered result in the IF-THEN statements…  (just throwing out ideas - I’m not sure if this will be a good match for your situation)

  • #5 / Jul 04, 2012 10:57am

    Dan Decker

    7338 posts

    Hi photek,

    ExpressionEngine doesn’t offer a variable setting and getting scheme out of the box, but a really great way to overcome this is to use an add-on like Stash.

    Stash can work within templates or have values stored in the database. And it plays nice with conditionals 😊

    Cheers,

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases