{"id":1260,"date":"2020-08-12T17:05:18","date_gmt":"2020-08-12T17:05:18","guid":{"rendered":"https:\/\/sweepwidget.com\/docs\/?p=1260"},"modified":"2026-11-19T10:29:38","modified_gmt":"2026-11-19T10:29:38","slug":"auto-login-user-with-pre-filled-data","status":"publish","type":"post","link":"https:\/\/sweepwidget.com\/docs\/auto-login-user-with-pre-filled-data","title":{"rendered":"Auto-Enter User From Your Website&#8217;s Logged In User Session \/ Cookie Data"},"content":{"rendered":"<p>Plan required: Premium or higher.<\/p>\n<p>You can pre-fill the name and email in the entry form for a user who is already logged in to your website, and optionally enter them into the giveaway automatically.<\/p>\n<p>Example: a user is logged in to your website and has not entered your giveaway yet. Pull their name and email from your session data and pass them to the widget. If you also turn on auto-login, the user is entered with that name and email without filling in the form.<\/p>\n<h2 id=\"embedded-giveaway\">Embedded giveaway<\/h2>\n<p>Add three attributes to the <code>sw_container<\/code> div of your embed code.<\/p>\n<p>Embed code without pre-fill:<\/p>\n<pre class=\"html\"><code>&lt;div id=&quot;29218-9c7ong3k&quot; class=&quot;sw_container&quot;&gt;&lt;script type=&quot;text\/javascript&quot; src=&quot;https:\/\/sweepwidget.com\/w\/j\/w_init.js?v=3&quot;&gt;&lt;\/script&gt;&lt;\/div&gt;<\/code><\/pre>\n<p>Attributes to add:<\/p>\n<pre class=\"html\"><code>data-email-prefill=&quot;name@email.com&quot;\ndata-name-prefill=&quot;John Doe&quot;\ndata-auto-login-prefill=&quot;1&quot;<\/code><\/pre>\n<p>Take the values from your session or cookie data. Set <code>data-auto-login-prefill<\/code> to <code>1<\/code> to log the user in automatically, or <code>0<\/code> to only pre-fill the form.<\/p>\n<p>Example in PHP (escape the values, they come from your own user data):<\/p>\n<pre class=\"php\"><code>&lt;div id=&quot;29218-9c7ong3k&quot; class=&quot;sw_container&quot;\n  data-name-prefill=&quot;&lt;?php echo htmlspecialchars($user[&#39;name&#39;], ENT_QUOTES); ?&gt;&quot;\n  data-email-prefill=&quot;&lt;?php echo htmlspecialchars($user[&#39;email&#39;], ENT_QUOTES); ?&gt;&quot;\n  data-auto-login-prefill=&quot;1&quot;&gt;&lt;script type=&quot;text\/javascript&quot; src=&quot;https:\/\/sweepwidget.com\/w\/j\/w_init.js?v=3&quot;&gt;&lt;\/script&gt;&lt;\/div&gt;<\/code><\/pre>\n<p>Names and emails are passed to the giveaway in its web address. If a value can contain characters such as <code>&amp;<\/code> or <code>+<\/code>, URL-encode it before you print it.<\/p>\n<h2 id=\"hosted-landing-page\">Hosted landing page<\/h2>\n<p>Pass the same information as parameters in the page address:<\/p>\n<ul>\n<li><code>data-name<\/code><\/li>\n<li><code>data-email<\/code><\/li>\n<li><code>data-auto-login<\/code> (<code>1<\/code> for yes, <code>0<\/code> for no)<\/li>\n<\/ul>\n<p>Example link:<\/p>\n<pre><code>https:\/\/sweepwidget.com\/c\/438-tu2zjsh4?data-name=Steven&amp;data-email=test.user@example.com&amp;data-auto-login=0<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Plan required: Premium or higher. You can pre-fill the name and email in the entry form for a user who is already logged in to your website, and optionally enter them into the giveaway automatically. Example: a user is logged in to your website and has not entered your giveaway yet. Pull their name and email from your session data and pass them to the widget. If you also turn on auto-login, the user is entered with that name and email without filling in the form. Embedded giveaway Add three attributes to the sw_container div of your embed code. Embed code without pre-fill: &lt;div id=&quot;29218-9c7ong3k&quot; class=&quot;sw_container&quot;&gt;&lt;script type=&quot;text\/javascript&quot; src=&quot;https:\/\/sweepwidget.com\/w\/j\/w_init.js?v=3&quot;&gt;&lt;\/script&gt;&lt;\/div&gt; Attributes to add: data-email-prefill=&quot;name@email.com&quot; data-name-prefill=&quot;John Doe&quot; data-auto-login-prefill=&quot;1&quot; Take the values from your session or cookie data. Set data-auto-login-prefill to 1 to log the user in automatically, or 0 to only pre-fill the form. Example in PHP (escape the values, they come from your own user data): &lt;div id=&quot;29218-9c7ong3k&quot; class=&quot;sw_container&quot; data-name-prefill=&quot;&lt;?php echo htmlspecialchars($user[&#39;name&#39;], ENT_QUOTES); ?&gt;&quot; data-email-prefill=&quot;&lt;?php echo htmlspecialchars($user[&#39;email&#39;], ENT_QUOTES); ?&gt;&quot; data-auto-login-prefill=&quot;1&quot;&gt;&lt;script type=&quot;text\/javascript&quot; src=&quot;https:\/\/sweepwidget.com\/w\/j\/w_init.js?v=3&quot;&gt;&lt;\/script&gt;&lt;\/div&gt; Names and emails are passed to the giveaway in its web address. If a value can contain characters such as &amp; or +, URL-encode it before you print it. Hosted landing page Pass the same information as parameters in the page address: data-name data-email data-auto-login (1 for yes, 0 for no) Example link: https:\/\/sweepwidget.com\/c\/438-tu2zjsh4?data-name=Steven&amp;data-email=test.user@example.com&amp;data-auto-login=0<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[62],"tags":[],"class_list":["post-1260","post","type-post","status-publish","format-standard","hentry","category-manage-entries"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Auto-login user with pre-filled data | SweepWidget<\/title>\n<meta name=\"description\" content=\"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.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/sweepwidget.com\/docs\/auto-login-user-with-pre-filled-data\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Auto-login user with pre-filled data | SweepWidget\" \/>\n<meta property=\"og:description\" content=\"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.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/sweepwidget.com\/docs\/auto-login-user-with-pre-filled-data\" \/>\n<meta property=\"og:site_name\" content=\"SweepWidget Help Docs\" \/>\n<meta property=\"article:published_time\" content=\"2020-08-12T17:05:18+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-11-19T10:29:38+00:00\" \/>\n<meta name=\"author\" content=\"SweepWidget\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"SweepWidget\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/sweepwidget.com\\\/docs\\\/auto-login-user-with-pre-filled-data#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/sweepwidget.com\\\/docs\\\/auto-login-user-with-pre-filled-data\"},\"author\":{\"name\":\"SweepWidget\",\"@id\":\"https:\\\/\\\/sweepwidget.com\\\/docs\\\/#\\\/schema\\\/person\\\/4cca2bc9c600116750eca1bfff6648e0\"},\"headline\":\"Auto-Enter User From Your Website&#8217;s Logged In User Session \\\/ Cookie Data\",\"datePublished\":\"2020-08-12T17:05:18+00:00\",\"dateModified\":\"2026-11-19T10:29:38+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/sweepwidget.com\\\/docs\\\/auto-login-user-with-pre-filled-data\"},\"wordCount\":199,\"articleSection\":[\"Manage Entries\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/sweepwidget.com\\\/docs\\\/auto-login-user-with-pre-filled-data\",\"url\":\"https:\\\/\\\/sweepwidget.com\\\/docs\\\/auto-login-user-with-pre-filled-data\",\"name\":\"Auto-login user with pre-filled data | SweepWidget\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/sweepwidget.com\\\/docs\\\/#website\"},\"datePublished\":\"2020-08-12T17:05:18+00:00\",\"dateModified\":\"2026-11-19T10:29:38+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/sweepwidget.com\\\/docs\\\/#\\\/schema\\\/person\\\/4cca2bc9c600116750eca1bfff6648e0\"},\"description\":\"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.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/sweepwidget.com\\\/docs\\\/auto-login-user-with-pre-filled-data#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/sweepwidget.com\\\/docs\\\/auto-login-user-with-pre-filled-data\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/sweepwidget.com\\\/docs\\\/auto-login-user-with-pre-filled-data#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/sweepwidget.com\\\/docs\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Auto-Enter User From Your Website&#8217;s Logged In User Session \\\/ Cookie Data\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/sweepwidget.com\\\/docs\\\/#website\",\"url\":\"https:\\\/\\\/sweepwidget.com\\\/docs\\\/\",\"name\":\"SweepWidget Help Docs\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/sweepwidget.com\\\/docs\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/sweepwidget.com\\\/docs\\\/#\\\/schema\\\/person\\\/4cca2bc9c600116750eca1bfff6648e0\",\"name\":\"SweepWidget\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d91c2f57672b440838a4205ff021607b3d77efd9ac80a80984ce065da067e51e?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d91c2f57672b440838a4205ff021607b3d77efd9ac80a80984ce065da067e51e?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d91c2f57672b440838a4205ff021607b3d77efd9ac80a80984ce065da067e51e?s=96&d=mm&r=g\",\"caption\":\"SweepWidget\"},\"sameAs\":[\"https:\\\/\\\/sweepwidget.com\\\/docs\"],\"url\":\"https:\\\/\\\/sweepwidget.com\\\/docs\\\/author\\\/sweepwidget\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Auto-login user with pre-filled data | SweepWidget","description":"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.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/sweepwidget.com\/docs\/auto-login-user-with-pre-filled-data","og_locale":"en_US","og_type":"article","og_title":"Auto-login user with pre-filled data | SweepWidget","og_description":"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.","og_url":"https:\/\/sweepwidget.com\/docs\/auto-login-user-with-pre-filled-data","og_site_name":"SweepWidget Help Docs","article_published_time":"2020-08-12T17:05:18+00:00","article_modified_time":"2026-11-19T10:29:38+00:00","author":"SweepWidget","twitter_card":"summary_large_image","twitter_misc":{"Written by":"SweepWidget","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/sweepwidget.com\/docs\/auto-login-user-with-pre-filled-data#article","isPartOf":{"@id":"https:\/\/sweepwidget.com\/docs\/auto-login-user-with-pre-filled-data"},"author":{"name":"SweepWidget","@id":"https:\/\/sweepwidget.com\/docs\/#\/schema\/person\/4cca2bc9c600116750eca1bfff6648e0"},"headline":"Auto-Enter User From Your Website&#8217;s Logged In User Session \/ Cookie Data","datePublished":"2020-08-12T17:05:18+00:00","dateModified":"2026-11-19T10:29:38+00:00","mainEntityOfPage":{"@id":"https:\/\/sweepwidget.com\/docs\/auto-login-user-with-pre-filled-data"},"wordCount":199,"articleSection":["Manage Entries"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/sweepwidget.com\/docs\/auto-login-user-with-pre-filled-data","url":"https:\/\/sweepwidget.com\/docs\/auto-login-user-with-pre-filled-data","name":"Auto-login user with pre-filled data | SweepWidget","isPartOf":{"@id":"https:\/\/sweepwidget.com\/docs\/#website"},"datePublished":"2020-08-12T17:05:18+00:00","dateModified":"2026-11-19T10:29:38+00:00","author":{"@id":"https:\/\/sweepwidget.com\/docs\/#\/schema\/person\/4cca2bc9c600116750eca1bfff6648e0"},"description":"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.","breadcrumb":{"@id":"https:\/\/sweepwidget.com\/docs\/auto-login-user-with-pre-filled-data#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/sweepwidget.com\/docs\/auto-login-user-with-pre-filled-data"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/sweepwidget.com\/docs\/auto-login-user-with-pre-filled-data#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/sweepwidget.com\/docs\/"},{"@type":"ListItem","position":2,"name":"Auto-Enter User From Your Website&#8217;s Logged In User Session \/ Cookie Data"}]},{"@type":"WebSite","@id":"https:\/\/sweepwidget.com\/docs\/#website","url":"https:\/\/sweepwidget.com\/docs\/","name":"SweepWidget Help Docs","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/sweepwidget.com\/docs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/sweepwidget.com\/docs\/#\/schema\/person\/4cca2bc9c600116750eca1bfff6648e0","name":"SweepWidget","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/d91c2f57672b440838a4205ff021607b3d77efd9ac80a80984ce065da067e51e?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/d91c2f57672b440838a4205ff021607b3d77efd9ac80a80984ce065da067e51e?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d91c2f57672b440838a4205ff021607b3d77efd9ac80a80984ce065da067e51e?s=96&d=mm&r=g","caption":"SweepWidget"},"sameAs":["https:\/\/sweepwidget.com\/docs"],"url":"https:\/\/sweepwidget.com\/docs\/author\/sweepwidget"}]}},"_links":{"self":[{"href":"https:\/\/sweepwidget.com\/docs\/wp-json\/wp\/v2\/posts\/1260","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sweepwidget.com\/docs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sweepwidget.com\/docs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sweepwidget.com\/docs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sweepwidget.com\/docs\/wp-json\/wp\/v2\/comments?post=1260"}],"version-history":[{"count":14,"href":"https:\/\/sweepwidget.com\/docs\/wp-json\/wp\/v2\/posts\/1260\/revisions"}],"predecessor-version":[{"id":7837,"href":"https:\/\/sweepwidget.com\/docs\/wp-json\/wp\/v2\/posts\/1260\/revisions\/7837"}],"wp:attachment":[{"href":"https:\/\/sweepwidget.com\/docs\/wp-json\/wp\/v2\/media?parent=1260"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sweepwidget.com\/docs\/wp-json\/wp\/v2\/categories?post=1260"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sweepwidget.com\/docs\/wp-json\/wp\/v2\/tags?post=1260"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}