There are so many articles about cookies
and localStorage
(setting, deleting...), but it's unclear for me where I should place some code.
Namely, I'm trying to change css stylesheet clicking on a button, but cannot save that choice for the next time the page is loaded. Something like:
params.php
if (user clicked on "btntheme") {
$theme = 'green.css';
}else{
$theme = "blue.css";
};
index.php
<?php include ("params.php");?>
<head>
<link id="link01" rel="stylesheet" href="<?php echo $theme;?>">
</head>
<body>
<div id="btntheme">THEME</div>
</body>
JS
$('#btntheme').click(function(){
$('#link01').attr('href', 'green.css');
});
This changes style but only for the current session. How can I tell to params.php
that in the future $theme
is green.css
, and not blue.css
?