[Javascript] Reading cookies

James Fox jfox at plus.net
Wed Apr 25 06:10:50 CDT 2001


Hi There,

Thanks for the information! 
However, I've never setup a cookie before, can you point me to a 
website with further info on setting/reading cookies?

Thanks very much.
James

On 25 Apr 2001, at 10:03, Rodney Myers wrote:

> James,
> 
> Getting the cookie value will give you a string such as you have
> reproduced.
> Then it is a matter of extracting the part you need.
> 
> In this the main tools would be :
> 
>   the string.split(X) method
>  - which you may know can split not just on single chars 
>    such as space or semi-colon but also on strings.
> 
>   the bigString.indexOf(X) method 
>  - which can return the position of small string X in bigString 
> 
> So if bigString had the total value
> 
> var temp = bigString.split("UB-NICKNAME")
> 
> would create an array in which temp[1] contained all the rest of
> bigString from (in your example) 'James' onwards.
> 
> 
> var pos=bigString.indexOf("UB-NICKNAME")
> would give you the position in bigString of the start of "UB-NICKNAME"
> By adding the length of "UB-NICKNAME" plus any line break chars you may
> have used (email makes long strings difficult to interpret literally)
> you can find the start of the value you need.
> 
> Then indexOf may be used again to find a char/string that will signal
> the end of the UB-NICKNAME. If there is no such string or char, then you
> may have to replan so that there is.
> 
> hth
> 
> Rodney
> 
> James Fox wrote:
> > 
> > mmmm cookies..
> > 
> > Okay, I have set up 'UltraBoard' which uses cookies to store the
> > user's username.
> > 
> > I want to read the cookie which UltraBoard leaves and display the
> > users' nickname on the front of my site. How do I go about this?
> > The cookie is called 'UB/' and part of the cookie looks like this:
> > (I want the part which says 'UB-NICKNAME')
> > Thanks very much.
> > 
> > EMAILjames%40lymm.netcgi.www.lymm.net/cgi-
> > bin/www.lymm.net/UB/0311876864029418535254969000029412500
> > *
> > UB-NICKNAME
> > James
> > cgi.www.lymm.net/cgi-
> > bin/www.lymm.net/UB/
> > 0
> > 3118768640
> > 29418535
> > 2549590000
> > 2
> > 9412500
> > *
> > UB-
> > 
> > --
> > | James Fox      Business Critical Web Applications available
> > | Web Developer  @ http://www.myopenapps.com
> > | PlusNet Technologies Ltd.
> > + ------ Internet Access Solutions @ http://www.plus.net ---------
> > 
> > _______________________________________________
> > Javascript mailing list
> > Javascript at LaTech.edu
> > http://www.LaTech.edu/mailman/listinfo/javascript
> 
> -- 
> Shop at ssistant Add-ons and Developer Workshops
> http://www.aflyingstart.net/addons/
> 
> 
> Rodney Myers
> Based in Oxford, England
> Technical Director, Shop at ssistant eCommerce Solutions
> 
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> http://www.LaTech.edu/mailman/listinfo/javascript
> 



-- 
| James Fox      Business Critical Web Applications available 
| Web Developer  @ http://www.myopenapps.com 
| PlusNet Technologies Ltd. 
+ ------ Internet Access Solutions @ http://www.plus.net --------- 




More information about the Javascript mailing list