I'm trying to track users using sessions, but no cookies.
All is well and good unless they go all the way back to the first page, then the session id variable resets itself for some reason.
I've tried fiddling with this 'SID' thing ( http://www.php.net/manual/en/function.session-id.php ), but to no avail.
You can see an example of what I'm dealing with here:
http://www.advantagegear.com/test/
If the visitor backs out to the first page, the session ID resets itself.
Here's the code:
index.php:
<?php
session_start();
if (isset($count))
{
$count++;
}
else
{
$count=1;
session_register('count');
$id=session_id();
}
print "<p>This is page one. Hello, ";
print $id;
print ".</p>
<form name=buy action=\"page2.php\" method=get>
<input type=submit name=submit value=Add>
An Antique Vase for 19.95";
$item_name="Antique Vase";
session_register('item_name');
$item_cost="19.95";
session_register('item_cost');
print "</form>";
page 2:
<?php
session_start();
session_register('qty');
print "Hello, $PHPSESSID. <br><br>You've added |$item_name| for |$item_cost| to your cart.<br><br>";
print "<a href=page3.php>Go here to pretend to checkout.</a>";
$count++;
print "<br><br>pageviews=|$count|";
?>
page 3:
<?php
session_start();
print "Hello, $PHPSESSID. <br><br>You've made it to page3, the checkout. <br><br>Hit your back button twice and see the session variables disappear.";
//print "number of items in cart: $qty";
$count++;
print "<br><br>pageviews=|$count|";
?>
I was thinking of having a splash page that automatically sets a session ID variable and redirects the visitor to the second page, but I'm hoping to not have to do that.
Any help, thanks.