Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-08-2004, 03:28 PM   PM User | #1
JAVAEOC
Regular Coder

 
Join Date: Oct 2003
Location: SC
Posts: 936
Thanks: 0
Thanked 0 Times in 0 Posts
JAVAEOC is an unknown quantity at this point
Using coooookies

How can i use use my cookies to retrive data?

Edit: a use too much --> delete
__________________
http://www.bluephoenix.uni.cc/
JAVAEOC is offline   Reply With Quote
Old 02-08-2004, 07:11 PM   PM User | #2
Antoniohawk
Senior Coder

 
Join Date: Aug 2002
Location: Kansas City, Kansas
Posts: 1,518
Thanks: 0
Thanked 2 Times in 2 Posts
Antoniohawk will become famous soon enough
Check out this tutorial on cookies.

http://hotwired.lycos.com/webmonkey/...tw=programming
Antoniohawk is offline   Reply With Quote
Old 02-08-2004, 07:56 PM   PM User | #3
JAVAEOC
Regular Coder

 
Join Date: Oct 2003
Location: SC
Posts: 936
Thanks: 0
Thanked 0 Times in 0 Posts
JAVAEOC is an unknown quantity at this point
<script>
var the_name = prompt("What's your name?","");
document.cookie = the_name;
alert("Thanks, now go to the next page.");
</script>

TO SET THE COOKY

<script>
var the_cookie = document.cookie;
alert("Your name is: " + the_cookie);
</script>

TO READ IT

but how did it know which cooky to read
__________________
http://www.bluephoenix.uni.cc/
JAVAEOC is offline   Reply With Quote
Old 02-08-2004, 08:07 PM   PM User | #4
Willy Duitt
Banned

 
Join Date: Sep 2003
Posts: 3,620
Thanks: 0
Thanked 0 Times in 0 Posts
Willy Duitt is an unknown quantity at this point
Quote:
Originally posted by JAVAEOC
but how did it know which cooky to read
Evidently, you looked at the first script example without reading the tutorial.

Perhaps you should try first reading the tutorial, then asking
for clarification on a particular point you do not understand.

.....Willy
Willy Duitt is offline   Reply With Quote
Old 02-08-2004, 08:11 PM   PM User | #5
JAVAEOC
Regular Coder

 
Join Date: Oct 2003
Location: SC
Posts: 936
Thanks: 0
Thanked 0 Times in 0 Posts
JAVAEOC is an unknown quantity at this point
I did read the tuturial thats how i knew i can delelte all the extra stuff

but on page 10 i get terrible lost
__________________
http://www.bluephoenix.uni.cc/

Last edited by JAVAEOC; 02-08-2004 at 08:14 PM..
JAVAEOC is offline   Reply With Quote
Old 02-08-2004, 09:00 PM   PM User | #6
JAVAEOC
Regular Coder

 
Join Date: Oct 2003
Location: SC
Posts: 936
Thanks: 0
Thanked 0 Times in 0 Posts
JAVAEOC is an unknown quantity at this point
Now I tried this
Code:
var broken_cookie = document.cookie.split(":");
var RightClick = broken_cookie[0];
var StyleNum = broken_cookie[1];
if(document.cookie==''){RightClick=0;StyleNum=0}
if(document.cookie==''){RightClick=0;StyleNum=0} this was for when the user logs on the page for the first time, so it still displays a style sheet.

This worked great on my PC
just as i wanted it to

but now i uploaded it to my server (brinkster.com) and it chages the cookie in some way it adds a weird Brinkster=0 or Brinkster=3 or sometimes just this #LSDAKJFSLKAF#DLKSJF0923490USD78923#@$LKSFJD

just random numbers and letters

this makes it impoosbile for me to retrive the information i stored.....

please help.

Here the link to the broken page -->

http://www34.brinkster.com/dgothe/db/DominiksBeta.html

it will alert the cookie value at the beginning so that you see whats going on

thanks alot
__________________
http://www.bluephoenix.uni.cc/
JAVAEOC is offline   Reply With Quote
Old 02-08-2004, 09:04 PM   PM User | #7
JAVAEOC
Regular Coder

 
Join Date: Oct 2003
Location: SC
Posts: 936
Thanks: 0
Thanked 0 Times in 0 Posts
JAVAEOC is an unknown quantity at this point
I added this:

var broken = document.cookie.split(";");
var broken_cookie = broken[1].split(":");

now it works.... thanks for all the given help
__________________
http://www.bluephoenix.uni.cc/
JAVAEOC is offline   Reply With Quote
Old 02-09-2004, 12:50 AM   PM User | #8
JAVAEOC
Regular Coder

 
Join Date: Oct 2003
Location: SC
Posts: 936
Thanks: 0
Thanked 0 Times in 0 Posts
JAVAEOC is an unknown quantity at this point
On this page i am using cookies
http://www34.brinkster.com/dgothe/db/DominiksBeta.html

they work great when i hit the refresh button but they do not work if i close the browser and reopen it

why?
JAVAEOC is offline   Reply With Quote
Old 02-09-2004, 01:07 AM   PM User | #9
Basscyst
Smokes a Lot


 
Join Date: Jul 2003
Location: CA, USA
Posts: 1,594
Thanks: 5
Thanked 20 Times in 20 Posts
Basscyst is on a distinguished road
You have to set the expiration date of the cookie.

http://hotwired.lycos.com/webmonkey/...tw=programming

Basscyst
__________________
Helping to build a bigger box. - Adam Matthews
Basscyst is offline   Reply With Quote
Old 02-09-2004, 01:46 AM   PM User | #10
JAVAEOC
Regular Coder

 
Join Date: Oct 2003
Location: SC
Posts: 936
Thanks: 0
Thanked 0 Times in 0 Posts
JAVAEOC is an unknown quantity at this point
GOSH

I am so lost please help me write a simple cookie script

i tried the tutorial but im too dumnb for it

please....

all i need is to store and retrive two variables.... please

thanks for any help
JAVAEOC is offline   Reply With Quote
Old 02-09-2004, 10:20 PM   PM User | #11
JAVAEOC
Regular Coder

 
Join Date: Oct 2003
Location: SC
Posts: 936
Thanks: 0
Thanked 0 Times in 0 Posts
JAVAEOC is an unknown quantity at this point
The script on this page doesnt work, why?

http://www34.brinkster.com/dgothe/cookie.htm

it works fine on my hard drive but it doesnt work when i upload it....

thnaks
JAVAEOC is offline   Reply With Quote
Old 02-10-2004, 03:56 AM   PM User | #12
glenngv
Supreme Master coder!


 
glenngv's Avatar
 
Join Date: Jun 2002
Location: Los Angeles, CA Original Location: Philippines
Posts: 10,241
Thanks: 0
Thanked 112 Times in 111 Posts
glenngv will become famous soon enough
One or more cookies can be saved in the browser. So cookie names do not always located at the start. In your page, the cookie string is:

BrinksterServer=1; cookey=muahah

Your script assumes the cookie is always at the start that's why your script fails when looking for cookey. There are many cookie scripts in the internet and in this forum, why not use them?

Here's one from Post a Javascript forum:
http://www.codingforums.com/showthre...threadid=11585
__________________
Glenn
_____________________________________________
Play Tower of Hanoi Android app (Ad-FREE!)
Play Tower of Hanoi Android app (FREE!)
Go to Tower of Hanoi Leaderboard
Play Tower of Hanoi Facebook app
glenngv is offline   Reply With Quote
Old 02-10-2004, 10:17 PM   PM User | #13
JAVAEOC
Regular Coder

 
Join Date: Oct 2003
Location: SC
Posts: 936
Thanks: 0
Thanked 0 Times in 0 Posts
JAVAEOC is an unknown quantity at this point
Glenn... thanks for that, but i already saw it...

Well the stuff they where doing there was WAY over my small head... So i wasnt able to throw together a working html file

that is why i started this thread...

so I would really appreciate it if you could throw together a working script and attach it....

thanks alot
JAVAEOC is offline   Reply With Quote
Old 02-11-2004, 01:52 AM   PM User | #14
glenngv
Supreme Master coder!


 
glenngv's Avatar
 
Join Date: Jun 2002
Location: Los Angeles, CA Original Location: Philippines
Posts: 10,241
Thanks: 0
Thanked 112 Times in 111 Posts
glenngv will become famous soon enough
The code in the link I gave you is already a working script and easy to use. It has attachment of the full documentation on its usage. Did you even try to create a simple page using that script?
__________________
Glenn
_____________________________________________
Play Tower of Hanoi Android app (Ad-FREE!)
Play Tower of Hanoi Android app (FREE!)
Go to Tower of Hanoi Leaderboard
Play Tower of Hanoi Facebook app
glenngv is offline   Reply With Quote
Old 02-11-2004, 02:27 AM   PM User | #15
JAVAEOC
Regular Coder

 
Join Date: Oct 2003
Location: SC
Posts: 936
Thanks: 0
Thanked 0 Times in 0 Posts
JAVAEOC is an unknown quantity at this point
glenngv... heres what i am having truble with:

OK the script works fine, the thing now is that when i alert(document.cookie) then it is supposed to alert all the cookies ... right?

but it doesnt it doesnt alert the cookie that i jsut set... why?

P.S. the reason why I didnt get the script to work is because i misspelled the cookie name lol and my javascirpt console is broke so....

thanks glenngv
JAVAEOC is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:14 AM.


Advertisement
Log in to turn off these ads.