Posted in: Giveaway Features

Auto-enter user from your website’s logged in user session/cookie data

In this article, we will learn how to auto-login a user with pre-filled data from your website. You can auto-fill the name, email, and whether or not to auto-log them in.

Example of how this works:

If a user a logged into your website and hasn’t entered a SweepWidget giveaway yet, you can auto-fill the name/email. You would be pulling this data from the session data on your website and populating the SweepWidget form with it. Furthermore, you can automatically have them enter the giveaway with this name/email combination.

Implementation instructions:

You will need to add 3 parameters to the embed code for your giveaway.

Here’s an example embed code:

<div id="20326-sav361e9" class="sw_container"><script type="text/javascript" src="https://sweepwidget.com/w/j/w_init.js"></script></div>

You would need to add the following 3 parameters:

data-email-prefill="[email protected]"
data-name-prefill="John Doe"
data-auto-login-prefill="1"

The values to each of these parameters would be pulled from your session or cookie data. Here’s an example implementation using PHP:

data-email-prefill="<?php echo $_COOKIE['user_email']; ?>"
data-name-prefill="<?php echo $_COOKIE['user_name']; ?>"
data-auto-login-prefill="1"

Also, you can set data-auto-login-prefill to either 1 or 0. If it’s set to 1 it will auto-log them in. If it’s set to 0, it won’t.