Streaming live at 10am (PST)

Redirect to last page visited

Hi there :slight_smile:

Can someone help with code writing (I’m not a coder) on redirecting to the last page visited. I have a site with member access (using SentryLogin) and a member area page and I’d like them to have the option of clicking a button to redirect to the last page they were on before they signed themselves out or were automatically signed out…is this possible within WF?

Thanks in advance!

What does the SentryLogin documentation say? Do you have a link for us to play around with?


Welcome to the Webflow forum!

Could you please edit Screenshot_2017-08-16_140811 and provide ALL the necessary details in your post so we can take a look at your site/issue?

In future if you want faster replies and more accurate answers, I suggest including all the details listed in the link above before someone has to ask.

Hope to hear from you soon. Thanks!

They haven’t developed anything like this and aren’t giving any definites as to if/when they will.

I did find some code on the web of how to do this and am having a bit of trouble implementing.

Here is the source: http://www.javascriptsource.com/navigation/redirect-to-last-page-visited.html

/* This script and many more are available free online at
The JavaScript Source!! http://www.javascriptsource.com */

/*******************************************************************************
 * Project: RestoreLastVisitedPage.js
 * Author: Dmitriy Simonchik (mailto: Dmitriy.Simonchik(at)gmail.com)
 * Modified: 29 Oct 2007
 * Web: http://www.thebridge.ru/last-visited-page/
 * Licence: LGPL
 * Remarks: If you improve this code, please share your modification
 *          Send your changes to me and I'll add them to the distribution.
 *          Thanks.
 ******************************************************************************/
// block of functions for work with cookies
function createCookie(name,value,days) {
	 if (days) {
		  var date = new Date();
		  date.setTime(date.getTime()+(days*24*60*60*1000));
  		var expires = "; expires="+date.toGMTString();
	 }
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	 var nameEQ = name + "=";
 	var ca = document.cookie.split(';');
 	for(var i=0;i < ca.length;i++) {
  		var c = ca[i];
  		while (c.charAt(0)==' ') c = c.substring(1,c.length);
  		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
 	}
	return null;
}

function eraseCookie(name) {
	 createCookie(name,"",-1);
}

// script body
// setting default values for parameters
if(typeof(dsLVPURLMainPage) == "undefined") {
  var loc = document.location.toString().split('/');
  var dsLVPURLMainPage = "http://" + loc[2] + "/";
}

if(typeof(dsLVPNotification) == "undefined")
  var dsLVPNotification = "You have been automatically redirected to last visited page on the site.";

//redirecting user to last visited page if he
//enters the site through main page
if(document.location == dsLVPURLMainPage) {
  //redirect only if user navigates to main page first time
  //in current session (if referrer not contains main page address)
  var storedData = readCookie("dsLVPURL");
  if(document.referrer.indexOf(dsLVPURLMainPage) == -1 && storedData != null) {
    LastVisitedPageURL = decodeURI(storedData);
    if(LastVisitedPageURL != null && LastVisitedPageURL != dsLVPURLMainPage) {
      document.location = LastVisitedPageURL;
      dsLVPMessage = dsLVPNotification;
    }
  }
}
// storing last visited page for a year in cookie
if(typeof(dsLVPDisabled) == "undefined")
  createCookie("dsLVPURL", encodeURI(document.location), 365);

I have hosted the js file here (copied/pasted exact code with no changes): http://yourjavascript.com/11333782051/restorelastvisitedpage.js

I have added the code to the head section with changing the src:

// URL of your site main page:
        // (If your site main page coincides with site domain name then you can omit this setting.)
        var dsLVPURLMainPage = "https://www.fantasyfootballmetrics.net/member-area";

        // Optional: Text of the message shown to user when he is automatically redirected:
        var dsLVPNotification = "You have been automatically redirected to last visited page on the site.";

        <script type="text/javascript" src="http://yourjavascript.com/11333782051/restorelastvisitedpage.js"></script>

The problem at this stage is the optional help text of this code displays on screen and both var’s aren’t being read as code either.

The code I put into the body seems to be working fine:

<script type="text/javascript">
<!--
  document.write(dsLVPMessage)
// -->
</script>

And due to the nature of the member only content, I’m sending the read-only link to you personally :slight_smile:

Thanks for looking into this!

This part is not wrapped in <script></script> tags.

I can’t see this file as the domain yourjavascript.com is blocked by my network connection.

So I ended up using the following code after searching the internet and jacking it up a few times then reading up on code some more lol

This seemed to be much easier for me to understand:



<style>
input[type=button] {
    color:white;
    font:3.4em open sans, ‘Century Gothic’, AppleGothic, sans-serif;
    font-size:14px;
    padding:14px;
    background:url(overlay.png) repeat-x center #ffcc00;
    background-color:#37b34a;
    border:1px solid #ffcc00;
    -moz-border-radius:10px;
    -webkit-border-radius:10px;
    border-radius:10px;
    border-bottom:1px solid #9f9f9f;
    -moz-box-shadow:inset 0 1px 0 rgba(255,255,255,0.5);
    -webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,0.5);
    box-shadow:inset 0 1px 0 rgba(255,255,255,0.5);
    cursor:pointer;
}
input[type=button]:hover {
    background-color:#fcd109;
}
</style>