CodeIgniter Forums
help, how can i retrieve a cookie value in a javascript file? im using mootols and i have an issue - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: help, how can i retrieve a cookie value in a javascript file? im using mootols and i have an issue (/showthread.php?tid=2614)



help, how can i retrieve a cookie value in a javascript file? im using mootols and i have an issue - El Forum - 08-14-2007

[eluser]fercho[/eluser]
hello,
im using mootools in my web page
take a look
www.tyresbolivia.com

but i'm having a problem,
i have links inside 3 sliders
when i press the links from a slider they redirect to a product page,
making the slider to close.

i want to keep the slider opened in which the product belongs.
so the only solution that i have is to pass with a cookie the slider number
and open it in the other page.

but i don't know how to do it.
please give me a hand
if you could address me to another solution i'll be very thankful.


help, how can i retrieve a cookie value in a javascript file? im using mootols and i have an issue - El Forum - 08-14-2007

[eluser]Derek Allard[/eluser]
2 good CodeIgniter solutions for that type of thing would be the cookie helper and the session library.


help, how can i retrieve a cookie value in a javascript file? im using mootols and i have an issue - El Forum - 08-14-2007

[eluser]fercho[/eluser]
yes, but i don't get how to call a cookie in a javascript file , could you give me an idea please??


help, how can i retrieve a cookie value in a javascript file? im using mootols and i have an issue - El Forum - 08-14-2007

[eluser]Derek Allard[/eluser]
If you are trying to implement a non-CI solution, there are many smart people on these forums who would be willing to help you, but there are also other great places on the net to learn it.

Here's a good start. http://www.w3schools.com/js/js_cookies.asp


help, how can i retrieve a cookie value in a javascript file? im using mootols and i have an issue - El Forum - 08-14-2007

[eluser]fercho[/eluser]
im willing to implement a ci solution because of that i want to know how to integrate this 3 things, ci , mootools and the cookies in javascript, ci is my first option, couldnt leave it.
i have searched the forums but i can't find a topic like this, please just a tip


help, how can i retrieve a cookie value in a javascript file? im using mootols and i have an issue - El Forum - 08-14-2007

[eluser]Michael Wales[/eluser]
You can do something like this:

Code:
my_jsVar = '<?= $this->session->userdata('my_ciVar'); ?>';



help, how can i retrieve a cookie value in a javascript file? im using mootols and i have an issue - El Forum - 08-14-2007

[eluser]Derek Allard[/eluser]
No problem.

http://codeigniter.com/wiki/Mootools/
http://stii.za.net/archives/98
http://pr0digy.com/codeigniter/unobtrusive-ajax-with-codeigniter-and-mootools/

and the mother of all links Wink


help, how can i retrieve a cookie value in a javascript file? im using mootols and i have an issue - El Forum - 08-14-2007

[eluser]fercho[/eluser]
thank you derek it will be my start, thanks again, you rock. i always visit your site.
and
walesmd can i do that in a <javascript> section??


help, how can i retrieve a cookie value in a javascript file? im using mootols and i have an issue - El Forum - 08-14-2007

[eluser]Michael Wales[/eluser]
Worth a shot - I don't see why you wouldn't be able to. Of course, it wouldn't work in a .js file - but as long as it's a .php file it should work.

Give it a try and let us know.


help, how can i retrieve a cookie value in a javascript file? im using mootols and i have an issue - El Forum - 08-14-2007

[eluser]fercho[/eluser]
yes, thaaaaaaaaanks again both of you , i will start right now to study all these great help you gave me, and i'll contact you with the fix, thank you very much.