小编lib*_*ire的帖子

php会话随机丢失,无法理解原因

我付了一个程序员来制作一个购物篮脚本来使用Spreadshirt API.一切都很完美,除了篮子一直在排空.我认为会话在某些时候丢失,所以脚本创建了另一个BasketId.

我试图找出它是否有特定原因发生,没有任何成功......我无法重现这个错误.它只是随机发生而没有任何理由.关闭浏览器,重置apache甚至整个网络服务器都不会引起会话丢失.

我有两个不同的脚本在同一个域上使用cookie,他们没有任何问题(一个是管理员登录会话的cookie,另一个cookie是保存用户在商店上最后查看的文章)

我尝试了谷歌上找到的所有解决方案没有任何成功:编辑php.ini,通过PHP强制ini设置,尝试了htaccess方式,...

这是我的phpinfo的"会话"部分:http://gyazo.com/168e2144ddd9ee368a05754dfd463021

shop-ajax.php (会议处理@第18行)

ini_set('session.cookie_domain', '.mywebsite.com' );
header("Pragma: no-cache");
header("Cache-Control: no-store, no-cache, max-age=0, must-revalidate");
$language = addslashes($_GET['l']);
$shopid = addslashes($_GET['shop']);


// if($_SERVER['HTTP_X_REQUESTED_WITH'] != 'XMLHttpRequest') {
//  die("no direct access allowed");
// }



if(!session_id()) {
  $lifetime=60 * 60 * 24 * 365;
  $domain = ".mywebsite.com";
   session_set_cookie_params($lifetime,"/",$domain);
    @session_start();
}





// Configuration
$config['ShopSource'] = "com";
$config['ShopId'] = $shopid;
$config['ShopKey'] = "*****";
$config['ShopSecret'] = "*****";



/*
 * add an article to …
Run Code Online (Sandbox Code Playgroud)

javascript php cookies ajax session

16
推荐指数
1
解决办法
3683
查看次数

Core ui选择不适合移动用户

我正在使用脚本"core ui select"在我的网站上设置我的表单样式.一切都适用于桌面用户,但是一段时间以来,有很多用户使用手机报告.他们说他们不能修改选项,因为它是灰色的.

所以我使用名为"默认用户代理"的firefox插件进行了测试,并将浏览器代理切换到iPhone.然后我意识到整个表单停止工作,但仅限于移动用户

这是一个测试页面,如果你想直接看到问题(你必须更改你的用户代理来重现这个bug):https: //www.ni-dieu-ni-maitre.com/test_mobile.php

这是页面的代码.

<script type="text/javascript" src="https://www.no-gods-no-masters.com/scripts/jquery-1.8.2.min.js"></script>
<link href="https://www.no-gods-no-masters.com/scripts/css/core-ui-select.css" media="screen" rel="stylesheet" type="text/css">
<link href="https://www.no-gods-no-masters.com/scripts/css/jquery.scrollpane.css" media="screen" rel="stylesheet" type="text/css">
    <script>
    $(document).ready(function(){
       $('#impression').coreUISelect();
    });
    </script>
</head><body>

<select class="b-core-ui-select__dropdown" name="impression" id="impression">
<option>Printing on front</option>
<option>Printing on back</option>
</select>

<script src="https://www.no-gods-no-masters.com/scripts/js/jquery.core-ui-select.js"></script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

javascript php forms jquery

12
推荐指数
1
解决办法
680
查看次数

谷歌字体在 Chrome 中不显示

我有一个非常奇怪的问题。

我在我的网站上使用谷歌字体。一切都可以在 Firefox、Internet Explorer 甚至 Opera 中正确显示。

但在 Google Chrome 中,显示的是“Comic sans MS”字体。

在此屏幕截图中,您可以看到 Firefox 和 Chrome 显示同一页面。该字体在 Firefox(左)中工作,但在 Chrome(右)中出现错误 http://gyazo.com/43462de300f4fb358cdf22c77e1955cd

您可以在这里看到该页面: https: //www.no-gods-no-masters.com/A-12443978/t-shirt-liberation-animale-vegetarien-vegan-ALF-animal-liberation-front

请注意,我还在浮动导航栏(顶部)上使用了另一种谷歌字体(Doppio One)。这个可以在 Chrome 中运行

字体在这里加载:

    @font-face {
    font-family: 'goboldregular';
    src: url('https://no-gods-no-masters.com/scripts/fonts/gobold-webfont.eot');
    src: url('https://no-gods-no-masters.com/scripts/fonts/gobold-webfont.eot?#iefix') format('embedded-opentype'),
         url('https://no-gods-no-masters.com/scripts/fonts/gobold-webfont.woff') format('woff'),
         url('https://no-gods-no-masters.com/scripts/fonts/gobold-webfont.ttf') format('truetype'),
         url('https://no-gods-no-masters.com/scripts/fonts/gobold-webfont.svg#goboldregular') format('svg');
    font-weight: normal;
    font-style: normal;

}
Run Code Online (Sandbox Code Playgroud)

html css fonts google-chrome

4
推荐指数
1
解决办法
2525
查看次数

SQL,带有小数条目的 varchar 字段 = ORDER BY 未正确排序

所以我有一个带有 VARCHAR 字段的表。它用于对很多小数值进行排序:

假设我的 VARCHAR 字段中有以下条目:

  • 9.99
  • 263.28
  • 9.98

假设我想使用 ORDER BY varchar DESC 显示所有条目。结果将是:

  • 9.99
  • 9.98
  • 263.28

显然263.28应该是第一个。怎么了 ?

php mysql sql math numbers

3
推荐指数
1
解决办法
1万
查看次数

php 将日期转换为时间戳

我正在尝试将 2 个日期转换为时间戳。一个是php生成的(今天的日期),另一个是用户输入的

$today = date("d-m-y");  // 01-12-13
$start_date = "28-11-13";

$todaytimestamp = strtotime($today);
$starttimestamp = strtotime($start_date);

echo "$today > $start_date <br>$todaytimestamp > $starttimestamp";
Run Code Online (Sandbox Code Playgroud)

问题是结果不正确

结果:

13年1月12日 > 11月13日28日 1008201600 > 1857686400

怎么了 ?

php string time timestamp date

3
推荐指数
1
解决办法
1万
查看次数

file_get_contents没有缓存?

我正在使用file_get_contents()从外部网站加载动态图像.

问题是图像已在远程网站上更新,但我的脚本仍然显示旧图像.我假设服务器在某处缓存图像,但是如何在使用file_get_contents获取文件时强制服务器清除缓存并使用更新的图像?

在我的本地机器上,我必须按CTRL + F5强制刷新图像.

我还尝试在我的脚本中添加无缓存标头,但它不起作用:

    $image = imagecreatefromstring(file_get_contents($path));
    header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
    header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date dans le passé
header('Content-type: image/png');
imagepng($image);
exit();
Run Code Online (Sandbox Code Playgroud)

php caching image file-get-contents

2
推荐指数
1
解决办法
8408
查看次数

在图像上隐藏用户的alt标签,但将它们保存在SEO的代码中

我的网站上有很多大图片(这是一件T恤店).<alt>为了SEO目的,我为标签添加了关键词.问题是,当加载图像时,<alt>标签会显示给用户,看起来很丑,因为<alt>标签非常长.

检查屏幕截图以查看问题

有没有办法隐藏<alt>用户的标签,但是将它们保存在代码中以帮助搜索引擎排名?

html

-1
推荐指数
1
解决办法
1489
查看次数