To main page | Opera Unite HowTo's
Cookies Haven't found a standard way to work with cookies, so here's a way to READ a cookie, based on jQuery's cookie plugin →:
Read a cookie function jQuery_trim( text ) {
return (text || "").replace( /^\s+|\s+$/g, "" );
};
function get_cookie(r, name) {
// Based on jQuery cookie plugin by Klaus Hartl
var cookieValue = '';
var cookies = r.connection.request.headers['Cookie'][0].split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery_trim(cookies[i]);
if (cookie.substring(0, name.length + 1) == (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;
}
};
return cookieValue;
};
then in URL response (see URLs):
function other_page(r) {
var cookie_value = get_cookie(r, 'cookie_name');
|