/    Sign up×
Community /Pin to ProfileBookmark

Links from cookies?

Ok, so I have these 2 cookies: ‘orderno’ and ‘gtotal’, and I need to post thier values into a <img> tag.

i need to have

[CODE]<img src=”https://www.twistoflemon.co.za/report?orderNumber=[B]orderno[/B]&orderValue=[B]gtotal[/B]”>
[/CODE]

the values in bold need to be loaded from my cookies.
can this be done?

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@nap0leonFeb 22.2012 — Can this be done, yes.

If you must use Javascript:

step 1 - find yourself a javascript cookies library you are happy with.

step 2 - use the "getCookieValue(cookiekey)" function (it will be named differently) from the library like this:
<i>
</i>var orderNumber = getCookieValue('orderno');
var orderValue = getCookieValue('gtotal');


Hopefully you can place an ID onto that image, so that the image is like:
<i>
</i>&lt;img id='Booyah' src="https://www.twistoflemon.co.za/report?orderNumber=orderno&amp;orderValue=gtotal"&gt;


Then you update the image's source, like this:
<i>
</i>document.getElementById('Booyah').src = 'https://www.twistoflemon.co.za/report?orderNumber=' + orderNumber + '&amp;orderValue=' + orderValue ;
Copy linkTweet thisAlerts:
@hyperionXSFeb 22.2012 — If your page is a PHP is even easier.
[code=html]
<img src="https://www.twistoflemon.co.za/report?orderNumber=<?php echo $_COOKIE['orderno']?>&orderValue=<?php echo $_COOKIE['gtotal']?>">
[/code]
Copy linkTweet thisAlerts:
@nap0leonFeb 22.2012 — Server side, very simple.

JavaScript, requires some cookie functions.

Classic ASP
<i>
</i>&lt;img src="https://www.twistoflemon.co.za/report?orderNumber=&lt;&amp;#37;=Request.Cookies("orderno")%&gt;&amp;orderValue=&lt;%=Request.Cookies("gtotal")%&gt;"&gt;
×

Success!

Help @Vampir3 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...