2

We're working on an EE site where we have a multi page registration process using FreeMember. Works great but we're experiencing issues in testing with users opting to use the 'back button' in their browser which results in them being returned to a registration screen where they then re-attempt registration (confusion ensues).

On completion of registration they are automatically logged in. Is there some best practice to deal with such situations? headers to prevent caching of the registration page (not sure that will work) or a jQuery snippet to sniff if they are logged in and redirect to a profile edit page if they are?

2

Ultimately I've decided on the really rather simple solution as follows. An EE template at 'site/ajax_is_logged_in' with the following markup:

{if logged_in}1{if:else}0{/if}

Then in the registration form template I use the following jQuery:

function is_logged_in() {
    $.get( "/site/ajax_is_logged_in", function(logged_in) {
        if (logged_in==1) {
            window.location.href = "/site/profile";
        }
    });
}

and just call it on page load. :)

1

You could add in a script that requires the page to reload/refresh if the user hits the back button. It's based on the time the page was first hit. Haven't tested this since I had it working on multi-page registration form.

<script type="text/javascript">
  $(document).ready(function() {
    var d = new Date();
    d = d.getTime();
    if ($('#reloadValue').val().length == 0) {
        $('#reloadValue').val(d);
        $('body').show(); // your site may not need this line
    } else {
        $('#reloadValue').val('');
        location.reload();
    }
  });
</script>
<input id="reloadValue" type="hidden" name="reloadValue" value="" />

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.