SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Mar 2005
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Cookie check for existance if not redirect

    trying to check that my cookie exists if it does then it is to display page else it should redirect to new page

    <HTML>
    <Head>


    <Script Language=JavaScript>

    var cookiecheck = GetCookie('mcjeeves.net') || 1;

    if ( cookiecheck == "" ) {
    window.location.replace("http://www.mcjeeves.net")
    }

    </Script>
    </Head>
    <Body>

    <h2><font color="red"><b><u><center>WELCOME TO OUR NEW WEB SITE!!!!</center></u></b>

    </body>

    </html>

  2. #2
    SitePoint Wizard gold trophysilver trophybronze trophy dc dalton's Avatar
    Join Date
    Nov 2004
    Location
    Right behind you, watching, always watching.
    Posts
    5,431
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you have to get the cookie prior to what you want to do here something like this:

    var myCookie = document.cookie;

    then loop thru it to find the info you want. Of course if you find nothing the cookie didnt exist AND Its been a LONG time since I did cookies but I pretty sure you can do this:

    if (myCookie != null) {

    }
    else {

    }

    I think?!?

  3. #3
    SitePoint Member
    Join Date
    Mar 2005
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i have also tried this im going wrong somewhere

    <HTML>
    <Head>


    <Script Language=JavaScript>


    function readcookie(mcjeeves.net){

    var start = document.cookie.indexOf(mcjeeves.net);

    if (start == -1){

    window.location="http://www.mcjeeves.net";

    }
    }






    </Script>
    </Head>
    <Body>

    <h2><font color="red"><b><u><center>WELCOME TO OUR NEW WEB SITE!!!!</center></u></b>

    </body>

    </html>

  4. #4
    SitePoint Member
    Join Date
    Mar 2005
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok im really confused as there are like half a tun of cookies on my machine how do i look for a specific cookie? im really bad at java i need to see the whole code to understand what it is doing can anybody help

  5. #5
    SitePoint Member
    Join Date
    Mar 2005
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Im not getting any where with this can anybody put me out of my misery


    PHP Code:
    <HTML>
    <
    Head>
    <
    Script Language=JavaScript>


    var 
    mycookie GetCookie('mcjeeves.net');



    if (
    myCookie != null)

    {
    window.location.replace("http://www.mcjeeves.net")
    }

    </Script>
    </Head>
    <Body>

    <h2><font color="red"><b><u><center>WELCOME TO OUR NEW WEB SITE!!!!</center></u></b>

    </body>

    </html> 


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
  •