Results 1 to 3 of 3

Thread: How can I use javascript to track session ID & Visitor ID cookies?

  1. #1
    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.

  2. #2
    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:

  3. #3
    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

Similar Threads

  1. How Google analytics ‘track’ visitor with the help of its code
    By chetna56 in forum Technology & Internet
    Replies: 4
    Last Post: 27-01-2011, 10:16 PM
  2. How does Google analytics track visitor through its code
    By Jezriah in forum Technology & Internet
    Replies: 4
    Last Post: 20-01-2011, 10:50 PM
  3. Diffrence between cookies and session variables
    By JEROLD12 in forum Software Development
    Replies: 5
    Last Post: 23-12-2009, 12:05 AM
  4. How do i track cookies
    By Dheran in forum Technology & Internet
    Replies: 2
    Last Post: 13-02-2009, 03:28 PM
  5. what is session and cookies
    By zoaib in forum Technology & Internet
    Replies: 1
    Last Post: 24-12-2008, 09:58 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,636,126.50514 seconds with 17 queries