Nodejs is a powerful platform which used for real-time data with flexible of handling data in file system or database side. Today tutorial we are going to discuss about the connecting MySql with Nodejs.
Before getting into our code part, first will discuss about things needed for MySql connecting with Nodejs then will move to our code side.
First we need to check the MySql package is installed in our current Nodejs version or not. We have the command to check list or individual package installed in Nodejs. If the package is installed it will display the package else show “(empty)” value.
Nodejs have the ability to track the connected and disconnected user IP Address with socket.io node package.
What is Socket.io ?
Socket.io enables real-time directions which is event based communication. Its works on all the platform, browser or device on reliability and speed. We need to check few package it’s installed or not. if not you can install socket.io and ip both package from your terminal.
Installing socket.io package
Installing ip package
Once you have installed both the packages, let’s include our needed package into our code and create server where our code will on that port.
var app = require('http').createServer(handler),
io = require('socket.io').listen(app),
ip = require('ip');
Tracking the impression using image tag it’s playing important role, whenever you are sending email or include the image tag into another website to display your ads. It will send the parameters and get back the logs.
How Impression tracker works
Impression tracker display the image using server-side file and send back user details to server. It’s used to track your ads which display in different websites.
Impression tracker using image tag – codeasearch.com
Let’s create simple image.html which have image tag and include image.php to display and capture logs entry. Continue reading →
Now a days most of the website are used to cache their data to reduce the server load, Also speed up the response. We are going to discuss about the APC – Alternative PHP Cache.
APC is a Alternative PHP Cache as I already mentioned, its used to cache the data, remove and expire in the given time. To work with APC first we need to enable php_apc.dll in windows and php_apc.so in Linux operating system.
Where to use APC ?
Consider you have a website with lots of content driven from database with data for all the users, on that time you cannot query the database each and every time. To avoid this case we will cache the data and share between the users. This will allow one time query and share the same data between the users.
Let’s see about fews function in APC.
apc_add – function used to store a data in key format and expire it in given TTL.
Cookie used to store user data in form of text file or memory and access the values from it, Cookie are the part of HTTP header.
What is Persistent Cookie ?
Persistent Cookie which will store the data in text file with expire date and time. If you are access the website or particular page cookie will be created based on cookie name. Next time If you are visiting the website or page it will be accessible from the cookie file which was created in the client browser.
Also Persistent Cookie is unsafe, because it will be easy viewable in the browser.
// creating the name:cookie_name_persistent and value:my cookie value with expire 1 hour
setcookie("cookie_name_persistent","my cookie value",time()+3600);
Above PHP file will create cookie and expire within 1 hour, you can view the cookie expire time in browser cookie part. Continue reading →