Dynamically manipulate php cookies with javascript/jquery

Posted by pundit on Stack Overflow See other posts from Stack Overflow or by pundit
Published on 2010-04-01T00:31:31Z Indexed on 2010/04/01 0:33 UTC
Read the original article Hit count: 422

Filed under:
|
|
|

Hi guys,

I'm currently building a dynamic menu bar(vertical and horizontal). in the default position its vertical. the user have the option to show the horizontal position and hide and vertical. I am currently doing that with javascript/ jquery. in order to keep the menu bar in the horizontal position i am keeping a count with a cookie. the problem is that when i use the click function in javascript i want to change the value of the cookie. i have no knowledge of how to do this. Can anyone assist me with this. all help would be appreciated.

 <?php
setcookie('menu', 1, time()+(86400));
 ?>
 $(document).ready(function() {

            $('#temp').hide();
            if(<?php echo $_COOKIE['menu'];?> == 1){
                $('#topmenu').hide();
                $('#sidemenu').floating().dropShadow().floating();
                $('#sidemenu_bottom').hide();
            }else{
                $('#topmenu').show();
                $('#topmenu').dropShadow();
                $('#sidemenu').hide();
                $('#sidemenu').removeShadow();
            }   

            $('#move').click(function(){

                $('#sidemenu').hide("drop",{},2000);
                $('#sidemenu').removeShadow();                  
                $('#topmenu').show();
                $('#topmenu').dropShadow();
                $('#sidemenu_bottom').show();
                $('#sidemenu_bottom').floating().dropShadow().floating();
            });

        });

This is what i have so far and the default cookie is working as well as the javascript. its just to change the cookie value now.

thanks.

© Stack Overflow or respective owner

Related posts about php

Related posts about JavaScript