<script> window.sessionStorage.setItem(['ScribeTransport'],['WebData']); </script>
pathとunix timeを入れます。
<script> var unix = Math.floor((new Date()).getTime()/1E3); var data = '{"path":"'+location.pathname+'", "time":"'+unix+'"}'; window.sessionStorage.setItem(['ScribeTransport'],[data]); </script>
ここまではOK
セットされたsessionを、JSON.parseで取り出す。
<script> var a = window.sessionStorage.getItem(['ScribeTransport']); b = JSON.parse(a); document.write(b.path); document.write(b.time); var unix = Math.floor((new Date()).getTime()/1E3); var data = '{"path":"'+location.pathname+'", "time":"'+unix+'"}'; window.sessionStorage.setItem(['ScribeTransport'],[data]); </script>
来た!
sessionから滞在時間とリファラーを抽出する
var a = window.sessionStorage.getItem(['ScribeTransport']); b = JSON.parse(a); var unix = Math.floor((new Date()).getTime()/1E3); document.write("リファラー" + b.path + "<br>"); document.write("滞在時間" +(unix - b.time)+ "秒"); var data = '{"path":"'+location.pathname+'", "time":"'+unix+'"}'; window.sessionStorage.setItem(['ScribeTransport'],[data]);
OKOKOK