Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to change cookie to session?
    primarykey
    data
    text
    <p>I'm new to session and cookie. Like the tile I want to change cookie to session. I just get code from the link here: <a href="http://www.pixelconnect.com.au/web-design-blog/php-css-theme-switcher-with-cookies" rel="nofollow">http://www.pixelconnect.com.au/web-design-blog/php-css-theme-switcher-with-cookies</a>? I've tried some way but it didn't work.</p> <p>before doctype:</p> <pre><code>&lt;?php $theme1 = business; $theme2 = modern; $theme3 = web2; if(isset($_POST['style'])) {setcookie('style', $_POST['style'], time()+(60*60*24*1000)); $style=$_POST['style'];} elseif(isset($_COOKIE['style'])) {$style=$_COOKIE['style'];} else {$style=$theme1;} ?&gt; </code></pre> <p>head:</p> <pre><code>&lt;head&gt; &lt;link href="&lt;?PHP echo $style; ?&gt;.css" rel="stylesheet" type="text/css" /&gt; &lt;/head&gt; </code></pre> <p>body:</p> <pre><code>&lt;body&gt; &lt;form action="&lt;?php echo $_SERVER["PHP_SELF"]; ?&gt;" method="post"&gt; &lt;select name="style"&gt; &lt;option &lt;?php echo "value='$theme1'"; if($style == $theme1) { echo "selected='selected'"; } ?&gt;&gt;&lt;?php echo $theme1; ?&gt;&lt;/option&gt; &lt;option &lt;?php echo "value='$theme2'"; if($style == $theme2) { echo "selected='selected'"; } ?&gt;&gt;&lt;?php echo $theme2; ?&gt;&lt;/option&gt; &lt;option &lt;?php echo "value='$theme3'"; if($style == $theme3) { echo "selected='selected'"; } ?&gt;&gt;&lt;?php echo $theme3; ?&gt;&lt;/option&gt; &lt;/select&gt;&lt;input type="submit" /&gt; &lt;/form&gt; &lt;/body&gt; </code></pre> <p>I'd like to do something like:</p> <pre><code>session_start(); $theme1 $theme2 $theme3 if(isset($_POST['style'])){ $style=$_POST['style'];} elseif(isset($_SESSION['style'])) {$style=$_SESSION['style'];} else {$style=$theme1;} ?&gt; </code></pre> <p>head:</p> <pre><code>&lt;link rel="stylesheet" type="text/css" href="&lt;?php echo $_SESSION['style']?&gt;" /&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload