Setting cookie when link clicked

So there’s this plugin for wordpress, Transposh: http://transposh.org/ its basically a translation engine.
I have this site i’m owrking on where when a user visits the site the site checks for Transposh’s Language preference cookie like this:

<?php if( isset( $_COOKIE['TR_LNG'] ) ) {} else { ?>

and if the cookie (called TR_LNG) is not found it proceeds to show a language selection dialogue, that has links to both English and French versions of the site. The problem is transposh’s own widget sets the default language like this: the suer selects language on widget. Widget loads required language page and displays a link below the widget that says Set this language as default.
The link looks like this:

Read More
<a id="tr_setdeflang" class="tr_setdeflang" onclick="return false;" href="http://sarvatma.org/wp-admin/admin-ajax.php?action=tp_cookie_bck">Set this lang....</a>

what I need to happen is, when a user clicks a language in the language preference dialogue that looks like this:

<a href="http://www.sarvatma.org/en/">In English</a>

I need it to also set the language, English in the above example as the default. That’s the best I can explain my situation, if you need anymore info just let me know.

Related posts

Leave a Reply

1 comment

  1. If I understand, you just need to bind the setting of a cookie to the clicking of the link?

    If so, you need to add an ID to your <a>:

    <a href="http://www.sarvatma.org/en/" id="mylink">In English</a>
    

    Then bind some cookie-setting code to the click event:

    (Using jQuery)

    $("a#mylink").bind("click", function() {
        $.cookie("TR_LNG", "English");
    });