# Detect new visitor

**URL:** <https://forum.kirupa.com/t/detect-new-visitor/218361>\
**Category:** Uncategorized\
**Created:** [March 7, 2007, 5:00am UTC](https://forum.kirupa.com/t/detect-new-visitor/218361 "2007-03-07T05:00:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Icy\_Penguin](https://avatars.discourse-cdn.com/v4/letter/i/f6c823/32.png) [@Icy\_Penguin](https://forum.kirupa.com/u/Icy_Penguin)\
**Post date:** [March 7, 2007, 5:00am UTC](https://forum.kirupa.com/t/detect-new-visitor/218361/1 "2007-03-07T05:00:25Z")

</div>

Hello everyone,

Just wondering how I should go about changing some a paragraph of text from ‘hello new user’ to ‘hello n00b’ if the user hasnt been to my site before.

so far I’ve been fooling around with this JS:

```auto

function bakeCookie(name,value,days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime()+(days*24*60*60*1000));
        var expires = "; expires="+date.toGMTString();
    }
    else var expires = "";
    document.cookie = name+"="+value+expires+"; path=/";
}

function salivateAfterCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++) {
        var c = ca*;
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
    return null;
}

function eatCookie(name) {
    bakeCookie(name,"",-1);
}

window.onload = function() {
    blah = document.getElementById('begin');
    if(salivateAfterCookie('visitor') == 'old') {    
        document.write('hello again')
    } else {
        document.write('hello n00b')    
    }
    bakeCookie('visitor', 'old', 999)
}

```

but, when i visit the page, only the ‘hello again’/‘hello n00b’ text displays, and the rest of the site doesnt.  
also, how can i get it to write into one specific div?

or shoudl i do all this in .php?

thanks
