Jump to content

User Session Information for 2 Pages


finkrattaz

Recommended Posts

I am trying to record when a user logs into a page and how long they were on the page. There two pages.

 

Page 1

 

<?php

session_start();

$_SESSION['view_start_sec_v1'] = date('s');

require_once('dbcon2.php');

if(isset($_POST['SUBMITME'])) {

$_SESSION['view_stop_sec_v1'] = date('s');

$dbr = new db;$dbr->dbuser();

$in = new customer;$in->inD($_POST['name'],$_POST['city'],$_POST['state'],$_POST['zip'],$_POST['make'],$_POST['model'],$_POST['completevideo'],$_POST['likevideo'],$_POST['purchasedvideo'],$_POST['comments'],1);

}

?>

 

Page 2

<?php

session_start();

$_SESSION['view_start_sec_v2'] = date('s');

require_once('dbcon2.php');

if(isset($_POST['SUBMITME'])) {

$_SESSION['view_stop_sec_v2'] = date('s');

$dbr = new db;$dbr->dbuser();

$in = new customer;$in->inD($_POST['name'],$_POST['city'],$_POST['state'],$_POST['zip'],$_POST['make'],$_POST['model'],$_POST['completevideo'],$_POST['likevideo'],$_POST['purchasedvideo'],$_POST['comments'],1);

}

?>

 

if ($_SESSION['view_start_sec_v1'] == $_SESSION['view_stop_sec_v1'])

{

// Its still the same hour..so parsing is fine.

$total_time_v1 = $_SESSION['view_stop_sec_v1'] - $_SESSION['view_start_sec_v1'];

$total_time_v2 = $_SESSION['view_stop_sec_v2'] - $_SESSION['view_start_sec_v2'];

$vp1_query = sprintf("INSERT INTO session(name, url_viewed, date_viewed,time_viewed) VALUES('%s','%s','%s','%s')", $name, 'VideoPage1',date('m/d/Y'), $total_time_v1);

$vp2_query = sprintf("INSERT INTO session(name, url_viewed, date_viewed,time_viewed) VALUES('%s','%s','%s','%s')", $name, 'VideoPage2',date('m/d/Y'), $total_time_v2);

mysql_query($vp1_query);

mysql_query($vp2_query);

}

 

Also in the database the time_viewed is set to VARCHAR and I don't know if it correct.

 

http://stealthtrackervideos.com is the site and the page where viewing the database is http://stealthtrackervideos.com/Session.php - Time Viewed is coming up as zero.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.