嘿你们我有这个网站http://www.taranmarlowjewelry.com/在右上角有一个购物车,但是当你第一次访问该网站时它不会出现,但是当你刷新页面时它出现了。
我一直在研究这个,我认为它与这个 cookie PHPSESSID 有关,因为当我删除那个 cookie 时,购物车又消失了。
我也被告知这是一个 PHP 配置问题。
我尝试像这样对我的 php5.ini 文件进行一些调整......
session.use_only_cookies = 1
session.use_trans_sid = 0
session.url_rewriter.tags = ""
但这没有用....我从这里得到它http://wordpress.org/support/topic/frontpage-slideshow-and-phpsessid-in-general-fix?replies=1
有谁知道我需要在我的 php 配置中调整哪些?
我试图在 wp-content/themes/twentyeleven/header.php 中设置一个cookie,就在这样的标签之后......
<?php
setcookie("PHPSESSID","6a52e6037be6342014834c475b6c0637","/","http://www.taranmarlowjewelry.com/")
?>
然后我得到这个错误......
Warning: setcookie() expects parameter 3 to be long, string given in /home/content/19/9468119/html/wp-content/themes/twentyeleven/header.php on line 54
当您第一次访问我的网站时,购物车不会显示,但当您刷新时,它仍会显示。
我什至像这样手动将cookie放入主题的functions.php文件底部......
function set_new_cookie() {
setcookie("PHPSESSID", '6a52e6037be6342014834c475b6c0637', time()+3600); /* expire in 1 hour */
}
add_action( 'init', 'set_new_cookie');
它设置它,它没有显示任何错误,但它不能解决我的问题。
我也在我的主题的functions.php文件中尝试了这个......
function set_new_cookie() {
set_cookie('PHPSESSID', '6a52e6037be6342014834c475b6c0637');
$_COOKIE['PHPSESSID'] = '6a52e6037be6342014834c475b6c0637';
}
add_action( 'init', 'set_new_cookie');
并得到了这个错误
Fatal error: Call to undefined function set_cookie() in /home/content/19/9468119/html/wp-content/themes/twentyeleven/functions.php on line 5
这是购物车表格...
<form class="product_search" style="font-size:0px !important;" method="GET" action="<?php echo $pp_url?>/" >
<input name="product_search" id="wpsc_search_autocomplete" class="wpsc_product_search wpsc_live_search_embed .wpsc_live_search" autocomplete="off" style="padding:0px !important; height:25px !important; vertical-align:top;" />
<script type='text/javascript' > /* <![CDATA[ */
jQuery('#wpsc_search_autocomplete').keypress( function(e){
if ( e.keyCode == 13 ) {
var url = '<?php echo $pp_url ?>'+'?product_search='+jQuery(this).val();
url = encodeURI(url);
jQuery(window.location).attr('href', url);
}
});
/* ]]> */
</script>
<input type="submit" id="button" name="button" class="searchBtn" value="GO"/>
</form>