Access a variable on a Site tab from within a Page

Has anyone figured this out yet? It should be quite simple, but it seems a lot of people have the question and nobody is able to give a working solution.

Basically, I have a form and I want field #input6 to take the URL of the previous page when I submit the form. I have 2 snippets of code - 1 from the Public Site and 1 from the page with the form.

Global site: ‘pageNavigation.js’
import { session } from ‘wix-storage’ ;
import wixLocation from ‘wix-location’ ;

let previousPageURL ;

$w . onReady ( function () {
previousPageURL = session . getItem ( “page” );
session . setItem ( “page” , wixLocation . url );
});

Page: With the Form
import wixData from ‘wix-data’ ;
import wixLocation from ‘wix-location’ ;

$w . onReady ( function () {
let url = wixLocation . url ;
$w ( “#input6” ). value = url ; // Line 6
});

The issue I have is that when I try to change ‘url’ in Line 6 to ‘previousPageURL’, I get a ‘cannot find field name’ error.