2013-06-13 5 views
1

로컬로 개발 한 사이트 (http://localhost888/develop)의 모든 페이지에 적용 할 쿠키를 구현하려고합니다. 웬일인지, 나는 그것을 'path /'를 더하여 일하게 할 수 없다.로컬 호스트에서 jQuery를 사용하여 쿠키 경로 지정

$(document).ready(function(){ 
var wrap = $('#viewMode'), 
viewMode = $.cookie('view-mode'); 
wrap.children().hide(); 

$('.js-view-mode').on('click', 'a',function(e){ 
e.preventDefault(); 
var t = $(this), 
type = t.attr('href'); 

if(t.parent().hasClass('s')) return; 

t.parent().addClass('s') 
.siblings().removeClass('s'); 

var lheight = $("#viewMode").height(); 
if(lheight != 0){ 
$("#viewMode").css("height",lheight+"px"); 
} 
wrap.children().fadeOut(); $(type).delay(500).fadeIn(function(){ 
$("#viewMode").css("height","auto"); 
}); 

viewMode = $.cookie('view-mode', type); 

}); 

if (viewMode) { 
$('.js-view-mode a[href='+ viewMode +']').trigger('click'); 
} else { 
$('.js-view-mode li:first a').trigger('click'); 
} 

}); 

나는 성공없이 3 라인에 다음 사항을 추가하려고했습니다 :

viewMode = $.cookie('view-mode', {path: '/'}); 

답변

0

$.cookie('the name')가 여기에

가 사용하는 전체 코드입니다 : 아래는 제가 현재 사용하고있는 코드는 쿠키 읽기를 위해 만들어졌습니다. 그래서 $.cookie('the name', the options)은 좋지 않습니다. 성공적으로`;

는 어떻게이`뷰 모드 = $ .cookie ('보기 모드')를 전송할 수, 구문 그래서 $.cookie('the_cookie', 'the_value', { opt1: foo, opt2: bar, ... });

+0

이다, 또는 옵션없이, 쿠키를 만들려면? 'the_value'는 무엇입니까? –

+0

'viewMode = $ .cookie ('view-mode');'그것을 얻으려면. '$ .cookie ('view-mode', type, {path : "\"});'설정하려면 – TCHdvlp

관련 문제