PHP - Is Setcookie Slow?
I am aiming to use setcookie to refresh the expiry of a cookie on EVERY page request.
Is this slow? I'm sure I can design things so i don't need to reset it on every page request, but if it isn't a big deal then I'll do it. Is setcookie slow? Similar Tutorialswould Java handle it faster? can PHP be made to handle it as fast? I really need help. check out my website and search cars for sale, then any distance and then 37919 zip. it takes too long and there are only 3351 cars on there now. before, when it only had about 2200 cars it was really fast. only about a 1000 cars made it slow. what could it be? nabacar.com It was returning results in about 15 seconds or less with 2200 cars. Now it is over a minute with only 1000 cars on it. I will have 150,000 on it when I get this sorted. http://nabacar.com some java was written to speed things up, but it didn't seem to help. Is it the server or the code causing this? For some reason I can not get this to work. Any thoughts? if( $row['password'] == $pass && $row['name'] == $user ) { $username = $row['name']; $uid = $row['id']; setcookie("id", $uid, 1400); //creates the first session var setcookie("username", $username, 1400); // second session var setcookie("loggedin", "1", 1400); echo "<script type=\"text/javascript\">alert(\"".$row['name']."Logged in as ".$_COOKIE['username'].".\"); window.location=\"index.php?OMG=loggedin\"</script>"; } I get a message box saying: "[username] Logged in as ." I've searched php.ini for corrupt cookie settings, nothing unusual. Hey Guys, I am trying to set a cookie so that when I registered user returns it Auto Logins them in. I am able to accomplish this on my Local server but as Soon as I upload to a web server to test it, it doesn't work. Is anyone able to shed some light on this for me. $usass = $mem['userid']; if (isset($_POST['rem'])) { $year = 3600*24*365; setcookie ("id" , "$usass", time()+$year); } if the code for setting the cookie, and the code for checking the cookie is Below if(isset($_COOKIE['id'])) { $_SESSION['userid'] = $_COOKIE['id']; print "<script>"; print " self.location='loggedin.php';"; // Comment this line if you don't want to redirect print "</script>"; } Hi, I'm working on a mac with MAMP, phpMyadmin. on localhost, also the mysql server is on my localhost. I've tested in either Safari and Firefox. I'm trying to set my cookie, and it doesn't work, and pulling my hair out. I'm trying out following script which should work, but it doesn't and it's driving me mad. I wanna check the cookie for when a person is or isn't logged in, so that i can show additional data on the .php page <html> <body> <?php $value = "my cookie value"; // send a cookie that expires in 24 hours setcookie("TestCookie",$value, time()+3600*24); // Print individual cookies echo $_COOKIE["TestCookie"]; // Print all cookies print_r($_COOKIE); ?> </body> </html> i have never been able to get this to work but i am at it agian in this code the php is not making the cookie can any one tell me why <?php function getRandomString($length = 5) { $validCharacters = "abcdefghijklmnopqrstuxyvwzABCDEFGHIJKLMNOPQRSTUXYVWZ+-*#&@!?1234567890"; $validCharNumber = strlen($validCharacters); $result = ""; for ($i = 0; $i < $length; $i++) { $index = mt_rand(0, $validCharNumber - 1); $result .= $validCharacters[$index]; } return $result; } setcookie("code", "getRandomString()", 3600000); echo getRandomString(); ?> Hello. I currently have a site that registered members can login in to and view the member only pages. Eventually I will be adding paypal code to purchase products. I use Session with an IF statement for all my members pages. Would it be beneficial at all to have cookies created for the users with setcookie? Or is this just a security risk waiting to happen? hello i use the fallowing code for my login page but it gives me the fallowing error i was wondering what is the problem? (line 179 is the setcookie) by the way it doesn't set the cookie any help would be appreciated error: Quote Warning: Cannot modify header information - headers already sent by (output started at /home2/sportsh9/public_html/test/login_acc.php:6) in /home2/sportsh9/public_html/test/login_acc.php on line 179 my code: <? include_once('functions.php'); function cleanQuery($string) { if(get_magic_quotes_gpc()) // prevents duplicate backslashes { $string = stripslashes($string); } $badWords = "(delete)|(update)|(union)|(insert)|(drop)|(http)|(--)"; $string = eregi_replace($badWords, "", $string); if (phpversion() >= '4.3.0') { $string = mysql_real_escape_string($string); } else { $string = mysql_escape_string($string); } return $string; } if (isset($_COOKIE['scmuser'])) { echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=index.php\">"; }else{ if ($_POST['username']) { //did they supply a password and username $username=cleanQuery($_POST['username']); $password=cleanQuery($_POST['password']); if ($password==NULL || $username==NULL) { ?> <p align="center"> <font color="#FF0000">Username or password wasn't supplied!</font><form action="login_acc.php" method="POST"> <table style="border:1px solid #FFFFFF;" width="90%" align="center"> <tr> <td align="center">Username: </td> <td align="center"> <input type="text" size="20" maxlength="25" name="username" /></td> </tr> <tr> <td align="center">Password: </td> <td align="center"> <input type="password" size="20" maxlength="25" name="password" /></td> </tr> <tr> <td align="center" colspan="2"> <input type="submit" value="Login"/> </td> </tr> <tr> <td align="center" colspan="2"> <a href="register.php">Register</a> - <a href="forgetpass.php">Forgot Your Password?</a> </td> </tr> </table> </form> <? }else{ $query = mysql_query("SELECT username,password FROM users WHERE username = '$username'") or die(mysql_error()); $data = mysql_fetch_array($query); if($data['password'] != $password) { ?> <p align="center"> <font color="#FF0000">The supplied login was incorrect</font><form action="login_acc.php" method="POST"> <table style="border:1px solid #FFFFFF;" width="90%" align="center"> <tr> <td align="center">Username: </td> <td align="center"> <input type="text" size="20" maxlength="25" name="username" /></td> </tr> <tr> <td align="center">Password: </td> <td align="center"> <input type="password" size="20" maxlength="25" name="password" /></td> </tr> <tr> <td align="center" colspan="2"> <input type="submit" value="Login"/> </td> </tr> <tr> <td align="center" colspan="2"> <a href="register.php">Register</a> - <a href="forgetpass.php">Forgot Your Password?</a> </td> </tr> </table> </form> <? }else{ $query = mysql_query("SELECT username,password FROM users WHERE username = '$username'") or die(mysql_error()); $row = mysql_fetch_array($query); setcookie("scmuser", "$username", time()+3600); echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=index.php\">"; } } } } ?> thank you I know PHP setcookie can set for all subdomains - by setting parameter 5 to something like ".domain.com". However, I have quite a lot of code that just leaves param 5 blank (so sets for the current subdomain of that server). Hopefully there'd be an easy way how to do this (a server setting?). I know you can use ini_set('session.cookie_domain','http://domain.com'); but that only seems to set the session cookie value, not ones set in PHP. I only really want it to ensure if someone accesses the site through both www.domain.com and domain.com that they use the same cookies. when a user logs in the cookie isnt being set. am i doing it wrong? if(empty($error)) { $query = $link->query("SELECT * FROM ".TBL_PREFIX."users WHERE u_username = '$username' AND u_password = '".asf_hash($password)."'") or die(print_link_error()); $row = $query->fetchAll(); $num_rows = $query->rowCount(); if($num_rows == 1) { if($row[0]['u_confirmed'] == 1) { setcookie('uid', $row[0]['u_uid'], time() + $session_length); // this cookie isnt being set echo 1; } else { $error = 'You Need To Activate Your Account'; } } else { if(!$error) { echo $lang->incorrect_login_details; } } } im doing a print_r on all cookies and it doesnt appear in the list. $session_length is set at 99999999 I am working on a login script and I am using cookies for the first time. I have it something like this: <?php if (correct user/pass entered) - set user/pass cookies ?> <html> <?php if (user/pass cookies are set) {echo 'you are logged in';} else {echo 'you are NOT logged in';} ?> </html> The problem is that if I enter a valid username and password, and the cookies are set, then I get the message 'you are NOT logged in' unless I leave the page then return to it, or if I refresh, in which case I get the message 'you are logged in'. Its almost as though I cannot use the cookies until I navigate away from the page on which they were set. Am I doing something wrong, or is this the way it works? I'm stumped on this one. New to sessions and cookies. When somebody logs out, the browser goes to logout.php. It logs them out, but the page shows this error: Warning: setcookie() expects parameter 3 to be long, string given in /data/21/2/40/160/2040975/user/2235577/htdocs/logout.php on line 23 you are now logged out. Code: [Select] <?php session_start(); if(!($_SESSION[id])){ $url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_server['PHP_SELF']); // check for trailing slash if ((subst($url, -1) == '/') OR (substr($url, -1) == '\\') ){ $url = substr($url, 0, -1); } $url .= '/index.php'; header("Location: $url"); exit(); } else { $_SESSION = array(); session_destroy(); setcookie ('PHPSESSID'. '', time()-300, '/', '', 0); } $page_title ='logged out!'; echo ' you are now logged out'; I hate header errors... I can never figure them out, im getting this error; Warning: Cannot modify header information - headers already sent by (output started at /home/damnpeti/public_html/restrict2.php:6) in /home/damnpeti/public_html/restrict2.php on line 62 Code: <?php $testDB = mysql_connect('localhost', $db_user, $db_pwd); mysql_select_db ($db_name); if (!$testDB) { die('Could not connect: ' . mysql_error()); } $surfer_ip = $_SERVER["REMOTE_ADDR"]; $str_sql = "select * from ".$db_table." where ipaddress='".$surfer_ip."'"; $result = mysql_query($str_sql); if ($row = mysql_fetch_assoc($result)) { $blocked_time = strtotime($row['blocked_time']); if($blocked_time != 0) { $current_time = time(); if($current_time - $blocked_time > 3600*24) //24 hours past { $str_sql = "delete from ".$db_table." where ipaddress='".$surfer_ip."'"; mysql_query($str_sql); $str_sql = "insert into ".$db_table." (ipaddress, surf_index) values('".$surfer_ip."', 1)"; mysql_query($str_sql); } else { die ("<center><div class='errors'>You have accessed this page too many times. To regain access, purchase a license or wait 24 hours.</div></center>"); } } else { if($row['surf_index'] < 2) { $str_sql = "update ".$db_table." set surf_index=surf_index+1 where ipaddress='".$surfer_ip."'"; mysql_query($str_sql); } else { $str_sql = "update ".$db_table." set blocked_time='".date ("Y-m-d H:i:s")."' where ipaddress='".$surfer_ip."'"; mysql_query($str_sql); die ("<center><div class='errors'>You have accessed this page too many times. To regain access, purchase a license or wait 24 hours.</div></center>"); } } } else { $str_sql = "insert into ".$db_table." (ipaddress, surf_index) values('".$surfer_ip."', 1)"; mysql_query($str_sql); } if(!isset($_COOKIE['surf_no'])) setCookie('surf_no', '1'); else setCookie('surf_no', $_COOKIE['surf_no']+1); if ($_COOKIE['surf_no'] > 2) die("<center><div class='errors'>You have accessed this page too many times. To regain access, purchase a license or wait 24 hours.</div></center>"); include 'http://damnitpetitions.com/cut/index3.php'; ?> Line 62 is if ($_COOKIE['surf_no'] > 2) I know it has something to do with the cookie... but Idk? I need the include there. If there include isnt where its at, the script is worthless. Ok, so basically someone submits a file (doc) and I need to see if it is the same as another file. So instead of opening 300+ files and checking for word similarity, I put the file info into a table called newnotes. Then check the file size for each of the notes in "newnotes" against all of the notes in the table "approvednotes" this could be something like matching 20 file sizes to 300+ file sizes. The user gets returned back to a page and this is all done in backend by the click of a button the admins can use. But would doing this slow down my server/website? Hi, I am having a problem with a part of my query: "SELECT SQL_CALC_FOUND_ROWS jobs.id AS jobId, enquiries.id AS profId, users.username, entity_details.name AS entityName, branches.name AS branch, orderNumber, entity_vat_numbers.vatCode, entity_account_numbers.accountNumber, (SELECT symbol FROM parts_trading, currencies WHERE parts_trading.enquiryRef = enquiries.id AND parts_trading.sellingCurrency = currencies.id LIMIT 1) AS symbol, (SELECT SUM(quantity) FROM parts_trading WHERE enquiryRef = enquiries.id) - COALESCE((SELECT SUM(quantity) FROM invoices_out_reference WHERE jobRef = jobs.id), 0) AS differentPartsCount, (SELECT SUM(quantity*sellingNet) FROM parts_trading WHERE parts_trading.enquiryRef = enquiries.id) - COALESCE( (SELECT SUM(invoices_out.net) FROM invoices_out, invoices_out_reference WHERE invoices_out_reference.invoiceRef = invoices_out.id AND invoices_out_reference.jobRef = jobs.id ) , 0) AS netRemaining, (SELECT SUM(quantity*sellingVat) FROM parts_trading WHERE parts_trading.enquiryRef = enquiries.id) - COALESCE( (SELECT SUM(invoices_out.vat) FROM invoices_out, invoices_out_reference WHERE invoices_out_reference.invoiceRef = invoices_out.id AND invoices_out_reference.jobRef = jobs.id ) , 0) AS vatRemaining, (SELECT SUM(quantity*(sellingNet+sellingVat)) FROM parts_trading WHERE parts_trading.enquiryRef = enquiries.id) - COALESCE( (SELECT SUM(invoices_out.net+invoices_out.vat) FROM invoices_out, invoices_out_reference WHERE invoices_out_reference.invoiceRef = invoices_out.id AND invoices_out_reference.jobRef = jobs.id ) , 0) AS totalRemaining FROM jobs, enquiries, users, branches, entity_details LEFT JOIN entity_account_numbers ON entity_details.id = entity_account_numbers.entityRef LEFT JOIN entity_vat_numbers ON entity_details.id = entity_vat_numbers.entityRef WHERE enquiries.traderRef = users.id AND jobs.enquiryRef = enquiries.id AND users.branchRef = branches.id AND (SELECT SUM(quantity) FROM parts_trading WHERE enquiryRef = enquiries.id) - COALESCE((SELECT SUM(quantity) FROM invoices_out_reference WHERE jobRef = jobs.id), 0) > 0 AND enquiries.entityRef = entity_details.id" I know for certain that it is the part: "AND (SELECT SUM(quantity) FROM parts_trading WHERE enquiryRef = enquiries.id) - COALESCE((SELECT SUM(quantity) FROM invoices_out_reference WHERE jobRef = jobs.id), 0) > 0" That is causing the problem. Unfortunately this is a vital part of my query used for not displaying rows that have quantities matching the sum of what is in the other table . Is there are more efficient way to get the same result than that part of the query? hey i have a problem when i try to send email through php it seems to take a long time somethings it can be there quickly but somethings it takes forever is it something im doing wrong in the short script this is part of my script Code: [Select] // email profile owner $webmaster = "admin@website.com"; $headers = "From: mywebsite<$webmaster>"; $subject = "$username has commented on your profile"; $message = "Hello $firstname $lastname. $username has posted a comment on your profile on mywebsite.com"; $message .= " The message $username has posted with is below.\n"; $message .= "\n****************************************************************\n"; $message .= "$comment"; $message .= "\n\n****************************************************************\n\n"; $message .= "Click here to view $username's profile $site/profile?id=$userid\n"; $message .= "Click here to view your profile $site/profile?id=$getid\n"; // send email mail($email, $subject, $message, $headers); I have swift mailer setup to send two message and plain and HTML. I have followed a lot of different posts and came up with a solution that works. However when I send for example 7k emails only about 500 made it out before the 30sec timeout. So I switched my timeout to 600secs and only about 3k made it out. I now I can switch my timeout to 0 or 3600sec and it will go through but it doesnt seem like this should take so long. I use Debian 6.0, Zimbra 7, Postfix, and SwiftMailer I am using the mailer like this; / Create the Transport $transport = Swift_SmtpTransport::newInstance('localhost', xx) ->setUsername('xxx') ->setPassword('xxx') ; // Create the Mailer using your created Transport $mailer = Swift_Mailer::newInstance($transport); //Starts the loop to separate the to email addresses everything past here is built for each email $to1 = explode(", ", $to); for($i = 0; $i < count($to1); $i++){ // Create a message $message = Swift_Message::newInstance($subject) ->setFrom(array($from => 'xxx')) ->setTo(array($to1[$i])) ->setBody($plaintxt) ->addPart($htmltxt, 'text/html'); $plaintxt = substr($plaintxt, 0, -$plaindumplength); $htmltxt = substr($htmltxt, 0, -$dumplength); $emailcounter += $mailer->send($message); } Hi, I coded this website in php http://www.3gar.info but it seem very slow. I checked the server but they said everything is ok and the website run smoothly in server. I have another copy of this website in hostmonister it run very fast there. http://www.ibuj.org Hi Guys We have had a holiday program written in php in the past by an experienced developer but we are experiencing problems now. So I am curious to try and resolve the best approach Here goes 1: We query multiple APIs to return holiday results to our users 2: This can take up to 20 seconds to return results but sometimes its much quicker depending on the volume of API returned results 3: Other users seem to be locked out of even visiting our website if an API call is running So initially without posting any code, I have a couple of questions which are A: Is there a way to maybe poll a process or allow partial results to the users browser while things run in the background ( similar to what other holiday providers seem to be doing ) B: Is there a way to speed this up or maybe some sort of better technology to utilise
Many thanks professionals Hi everyone, I have a data analysis system which, however, takes too long to insert data into the db. Can you help me understand where I went wrong? thank you DB MYSQL:
1 analytics_number bigint(20) AUTO_INCREMENT --------------------------------------------------------------------------- CLASS PHP Analytics.php class analytics {
public $search_sites; public function get_analytics_enter($visitor_ip, $visitor_visitor_id, $visitor_session_id, $visitor_pageview_id, $visitor_referrer, $visitor_url, $visitor_resolution, $visitor_viewport, $visitor_document){ try{
$GET_array = array("visitor_ip" => $visitor_ip, "visitor_visitor_id" => $visitor_visitor_id, "visitor_session_id" => $visitor_session_id, "visitor_pageview_id" => $visitor_pageview_id, "visitor_referrer" => $visitor_referrer, "visitor_url" => $visitor_url, "visitor_resolution" => $visitor_resolution, "visitor_viewport" => $visitor_viewport, "visitor_document" => $visitor_document);
$query = "SELECT * FROM analytics WHERE visitor_visitor_id = '".$visitor_visitor_id."'"; $visitor_ip_info = get_data_visitor($visitor_ip);
$visitor_visitor_pageview = 0;
$session_buffer = array();
$visitor_visitor_pages = array();
$analytics["visitor_session_landingpage"] = NULL;
foreach ($visitor_data as $visitor) {
if (!in_array($visitor["visitor_page_path"], $visitor_visitor_pages)) {
if ($visitor["visitor_session_id"] == $visitor_session_id) {
if ($visitor_session_pageview == 1) {
if (!in_array($visitor["visitor_page_path"],$visitor_session_pages)) {
if (!in_array($visitor["visitor_session_id"],$session_buffer)) {
if (!in_array($visitor_session_id,$session_buffer)) {
foreach($GET_array as $key => $value) {
$analytics["visitor_visitor_sessions"] = $visitor_visitor_session;
$analytics["visitor_visitor_pageviews"] = $visitor_visitor_pageview + 1; $analytics["visitor_visitor_time"] = "0";
$analytics["visitor_session_pageviews"] = $visitor_session_pageview + 1;
$analytics["visitor_enter_timestamp"] = date("d.m.Y, H:i:s");
$analytics["visitor_leave_timestamp"] = date("d.m.Y, H:i:s"); $analytics["visitor_pageview_time"] = "0";
$analytics["visitor_country"] = $visitor_ip_info["country"];
$analytics["visitor_referrer_url"] = $visitor_referrer;
$analytics["visitor_domain"] = $this->get_domain($visitor_url);
if (!in_array($analytics["visitor_page_path"], $visitor_visitor_pages)) {
if (!in_array($analytics["visitor_page_path"], $visitor_session_pages)) {
$analytics["visitor_visitor_pages"] = json_encode($visitor_visitor_pages);
if ($analytics["visitor_session_pageview"] == 1) {
$sql_1_1 = "UPDATE analytics SET " . "visitor_visitor_last_page" . "='" . "" . "' WHERE " . "visitor_visitor_id" . "='" . $visitor_visitor_id . "'";
$sql_1 = $sql_1_1."; ".$sql_1_2.";";
$analytics["visitor_visitor_last_page"] = "true";
$analytics["visitor_device"] = visitor_device(); $analytics["visitor_pageview_update"] = date("YmdHis");
$sql_2_1 = "INSERT INTO analytics ("; $this->_db->exec($sql_2_1); $sql_2_2 = "UPDATE analytics SET " . "visitor_visitor_sessions" . "='" . $analytics["visitor_visitor_sessions"] . "' WHERE " . "visitor_visitor_id" . "='" . $visitor_visitor_id . "'"; $sql_2_3 = "UPDATE analytics SET " . "visitor_visitor_pageviews" . "='" . $analytics["visitor_visitor_pageviews"] . "' WHERE " . "visitor_visitor_id" . "='" . $visitor_visitor_id . "'"; $sql_2_4 = "UPDATE analytics SET " . "visitor_visitor_pages" . "='" . $analytics["visitor_visitor_pages"] . "' WHERE " . "visitor_visitor_id" . "='" . $visitor_visitor_id . "'"; $sql_2_5 = "UPDATE analytics SET " . "visitor_session_pageviews" . "='" . $analytics["visitor_session_pageviews"] . "' WHERE " . "visitor_session_id" . "='" . $visitor_session_id."'"; $sql_2_6 = "UPDATE analytics SET " . "visitor_session_pages" . "='" . $analytics["visitor_session_pages"] . "' WHERE " . "visitor_session_id" . "='" . $visitor_session_id."'"; $sql_2_7 = "UPDATE analytics SET " . "visitor_session_landingpage" . "='" . $analytics["visitor_session_landingpage"] . "' WHERE " . "visitor_session_id" . "='" . $visitor_session_id."'"; $sql_2_8 = "UPDATE analytics SET " . "visitor_session_exitpage" . "='" . $analytics["visitor_session_exitpage"] . "' WHERE " . "visitor_session_id" . "='" . $visitor_session_id."'";
$sql_2 = $sql_2_2.";".$sql_2_3.";".$sql_2_4.";".$sql_2_5.";".$sql_2_6.";".$sql_2_7.";".$sql_2_8.";";
} catch(PDOException $e) { public function get_analytics_update($visitor_visitor_id, $visitor_session_id, $visitor_pageview_id, $visitor_pageview_time, $visitor_leave_url){
try{ $query = "SELECT MAX(" . "visitor_session_time" . ") FROM analytics WHERE " . "visitor_visitor_id" . "='" . $visitor_visitor_id . "' AND " . "visitor_session_id" . "='" . $visitor_session_id . "' ORDER BY " . "visitor_enter_id" . " DESC LIMIT 1"; $visitor_session_time = $this->_db->query($query)->fetchColumn();
$query = "SELECT MAX(" . "visitor_pageview_time" . ") FROM analytics WHERE " . "visitor_visitor_id" . "='" . $visitor_visitor_id . "' AND " . "visitor_session_id" . "='" . $visitor_session_id . "' AND " . "visitor_pageview_id" . "='" . $visitor_pageview_id . "' ORDER BY " . "visitor_enter_id" . " DESC LIMIT 1"; $analytics = array();
foreach($GET_array as $key => $value) {
$analytics["visitor_leave_timestamp"] = date("d.m.Y, H:i:s");
$analytics["visitor_visitor_time"] = $visitor_visitor_time + ($visitor_pageview_time - $visitor_pageview_time); $analytics["visitor_pageview_update"] = date("YmdHis");
if (isset($visitor_leave_url)) {
$sql_1_1 = "UPDATE analytics SET ";
} catch(PDOException $e) {
function visitor_referrer_type($referrer) {
if ($referrer == "") {
$referrer = explode(".",$referrer);
if (array_key_exists($referrer,$search_sites)) {
function visitor_referrer_name($referrer) {
if ($referrer == "") {
$referrer = explode(".",$referrer);
if (array_key_exists($referrer,$search_sites)) {
function visitor_leave_type($leave_url)
if ($leave_url == "") {
if (strpos($leave_url, $url_paz) !== false) {
function visitor_leave_name($leave_url) $leave_url = $this->get_domain($leave_url);
$leave_url = explode(".",$leave_url); } ?> analytics-db.php
<?php // Dataset IDs
array_push($database_structure["analytics"],"visitor_visitor_id"); // Dataset Visitor Data
array_push($database_structure["analytics"],"visitor_visitor_sessions"); // Dataset Session Data
array_push($database_structure["analytics"],"visitor_session_pageviews"); // Dataset Pageview Data // Dataset Enter Time
array_push($database_structure["analytics"],"visitor_enter_timestamp"); // Dataset Leave Time
array_push($database_structure["analytics"],"visitor_leave_timestamp"); // Dataset Geolocation
array_push($database_structure["analytics"],"visitor_country"); // Dataset Technology
array_push($database_structure["analytics"],"visitor_device"); // Dataset Referrer
array_push($database_structure["analytics"],"visitor_referrer_url"); // Dataset Page
array_push($database_structure["analytics"],"visitor_url"); // Dataset Time array_push($database_structure["analytics"],"visitor_pageview_time"); // Dataset Leave
array_push($database_structure["analytics"],"visitor_leave_url"); // Dataset Update
array_push($database_structure["analytics"],"visitor_pageview_update"); analytics-enter.php <?php
if(isset($_POST["visitor_ip"])){ ?> analytics-update.php <?php $analytics->get_analytics_update($_POST["visitor_visitor_id"], $_POST["visitor_session_id"], $_POST["visitor_pageview_id"], $_POST["visitor_pageview_time"], $_POST["visitor_leave_url"]); ?> JS FILE $(function(){
function create_cookie(name,value,days) {
var host = window.location.hostname;
document.cookie = name+"="+value+expires+"; path=/; domain=." + domain;
function read_cookie(name) {
while (c.charAt(0) == ' ') {
if (c.indexOf(nameEQ) == 0) {
function random_string(length, chars) {
function create_id() {
function create_visitor_visitor_id() {
function visitor_visitor_id() {
function create_visitor_session_id() {
function visitor_session_id() {
if (new URL(window.location.href).searchParams.get("analytics") != "true") { var analytics_script_location = "/analytics/controllers/";
var screen_width = screen.width;
var viewport_width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
var document_width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
var visitor_ip;
var visitor_visitor_id = visitor_visitor_id();
var visitor_enter_time = new Date();
var visitor_resolution = screen_width + "x" + screen_height; var visitor_leave_url = "NULL"; var current_time = 0;
var scroll_sum = 0;
var visitor_enter_sent = false;
var current_viewport_width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
var current_viewport = current_viewport_width + "x" + current_viewport_height;
var current_document = current_document_width + "x" + current_document_height;
function track_a_href(event) {
function analytics_visitor_enter() {
$.ajax({
function analytics_visitor_update() {
$.ajax({
window.setInterval(function() {
function analytics_visitor_leave() {
function visitor_leave_delay(time) {
$(window).load(function() { analytics_visitor_enter(); }); } }); Let's say I have a forum with 300 active people posting 24/7 I have error reporting turned off. But if I turn it on, it shows 100-200 Undefined variable's error's on each forum page, even if it's off does it effect performance or does it matter if the php is writing to a error_log? If so how can I disable php writing to a error_log as I have no sense or no need for it. Thanks, and would the speed be noticable if I went ahead and fixed all the errors, if it would help? or no I code fine, it's just i dont use the isset.. |