A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Simple cookie question

  1. #1
    I have what i bet is a very simple problem. I have two pages: index.html and flash.html

    index.html has a flash redirect to flash.html if the user has version 5. It's also going to have a bunch of other crap on it... download link, text for search engines, blah blah blah.

    what i would like is to have flash.html set a cookie, so next time the user comes back they automatically end up at flash.html instead of having to reload all of the crap on index.html before the flash redirect kicks in.

    I don't know javascript at all, so i would love it if somebody could help me out with the bit of code i need to put on flash.html to set the cookie, and the bit of code i need to put on index.html to read the cookie and redirect them if the value is "yes"

    Thanks!

    spyder

  2. #2
    Senior Member
    Join Date
    Aug 2000
    Posts
    1,317
    hi,
    in the index page:
    <script language="javascript">
    function readCookie(){
    // checking for the cookie
    if(document.cookie != "") {
    document.location = "flash.htm";
    }
    }
    </script>
    </head>

    <body bgcolor="#FFFFFF" text="#000000" onLoad="readCookie()">

    in the flash page:
    <script language="javascript">
    function makeCookie(){

    if(document.cookie == "") {
    // the cookie expires on this date
    var date = new Date("may 14, 2002");
    // make the cookie date readable by the browser
    var da_date = date.toGMTString();
    var da_cookie = "visited:True" + ";expires=" + da_date;
    document.cookie = da_cookie;
    //uncomment the alert below to see the cookies value
    //alert(da_cookie)
    }


    }
    </script>
    </head>

    <body bgcolor="#FFFFFF" text="#000000" onLoad="makeCookie()">

    good luck

  3. #3
    Thanks!

  4. #4
    hrm... the cookie script seems to be working great, except for the fact that it still wants to load that index.html page in before it redirects... so i get a blink of crap before i head to my flash page. I need all the crap to be on the index page for the search engines tho... any ideas?

  5. #5
    Member
    Join Date
    Jun 2001
    Posts
    48

    Another redirect

    Perhaps if the user isn't redirected to the flash page, they get redirected to the page with the html stuff...


    eg:
    Code:
    <script language="javascript"> 
    function readCookie(){ 
    // checking for the cookie 
    if(document.cookie != "") { 
    document.location = "flash.htm"; 
    }
    else {
    document.location = "htmlpage.htm";
    }
    } 
    </script> 
    </head> 
    
    <body bgcolor="#FFFFFF" text="#000000" onLoad="readCookie()">

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center