Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 20-06-2009
Member
 
Join Date: Jan 2009
Posts: 67
How can I use javascript to track session ID & Visitor ID cookies?

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.
Reply With Quote
  #2  
Old 20-06-2009
Member
 
Join Date: Jan 2009
Posts: 85
Re: How can I use javascript to track session ID & Visitor ID cookies?

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

Code:
 session_start();

// create a session variable 'username' with value 'icemelon'
$_SESSION['username'] = 'icemelon';

// print out "Welcome <USERNAME>" message
echo "<p> Welcome $_SESSION[username]! ";
For details:
Reply With Quote
  #3  
Old 20-06-2009
Member
 
Join Date: Nov 2008
Posts: 69
Re: How can I use javascript to track session ID & Visitor ID cookies?

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:
Code:
<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>
Here is a tutorial
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How can I use javascript to track session ID & Visitor ID cookies?"
Thread Thread Starter Forum Replies Last Post
How Google analytics ?track? visitor with the help of its code chetna56 Technology & Internet 4 27-01-2011 10:16 PM
How does Google analytics track visitor through its code Jezriah Technology & Internet 4 20-01-2011 10:50 PM
Diffrence between cookies and session variables JEROLD12 Software Development 5 23-12-2009 12:05 AM
How do i track cookies Dheran Technology & Internet 2 13-02-2009 03:28 PM
what is session and cookies zoaib Technology & Internet 1 24-12-2008 09:58 PM


All times are GMT +5.5. The time now is 12:54 AM.