Hi,
I want to know how to use javascript to track the session ID & Visitors of the website?
I am new to this please help.
Hi,
I want to know how to use javascript to track the session ID & Visitors of the website?
I am new to this please help.
Hello.
Sessions allow you to create variables which can be accessed by any page on your site. This means you don't have to send values via $_POST or $_GET (which are visible to the user). Your session variables exist across browser windows (of the same application). In other words, if you generate a session variable from one IE browser window.
All your session variables/values are stored in the array $_SESSION
For details:Code:session_start(); // create a session variable 'username' with value 'icemelon' $_SESSION['username'] = 'icemelon'; // print out "Welcome <USERNAME>" message echo "<p> Welcome $_SESSION[username]! ";
As the session ID is either transported over the URL (document.location.href) or via a cookie (document.cookie), you could check both for the presence of a session ID.
normally php will attempt to write the session in a cookie on the users pc, so it shouldn't be a problem that you don't see the session id.
This is an example of how to set a cookie in your HTML pages:
Here is a tutorialCode:<html> <head> <title>Test Page</title> <script src=”test.js” mce_src=”test.js”></script> <script language=”javascript”> //This line could be used to set a cookie manually //Set_Cookie( “key” , “val” , cookie_expire_date , “/stuff” , false ); //This line is used to set a visitor ID, which is easier setVisitorID(); </script> </head> <body> <br>This is only a test.<br> </body> </html>
Bookmarks