如何在没有cookie的情况下在PHP / JS中创建计数器? [英] How do I make counter in PHP/JS without cookies?

查看:111
本文介绍了如何在没有cookie的情况下在PHP / JS中创建计数器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hey Codeproject,



我不确定这些是什么。我是PHP / JS / HTML的新手,我正在尝试制作一个计数器 - 不是访客计数器,而是功能计数器。我希望能够记录我的Javascript函数search()被调用了多少次,然后以动态方式显示计数器(一旦其他人使用了搜索(),每个人都会更新。



*有没有人对如何做到这一点有任何想法?

*是否可以在。或.js文件中执行<?php?>?



问候,

- Eddie



我有什么尝试过:



尝试查看访客计数器,但他们使用cookies而我不想使用这些。

Hey Codeproject,

I wasn't sure what these are called. I'm new to PHP/JS/HTML and I'm trying to make a counter - not a visitor counter, but a function counter. I want to be able to log how many times my Javascript function search() has been called, and then display the counter in a dynamic fashion(updates for everyone once someone else has used search().

* Does anyone have any ideas on how to go about doing this?
* Is it possible to execute <?php ?> inside a or .js file?

Regards,
- Eddie

What I have tried:

Tried looking at visitor counters, but they use cookies and I do not want to use these.

推荐答案

1.作为cookie的替代方案,请查看 HTML5本地存储 [ ^ ]

2.永不结婚客户端脚本(JS)与服务器端脚本(PHP) - 如果一个断开,所有地狱也松了!相反,领事谷歌使用AJAX。
1. As an alternative to cookie, check out HTML5 Local Storage[^]
2. Never never couple client-side script (JS) with server-side one (PHP) - if one breaks, all hell breaks loose too! Instead, consult Google on the use of AJAX.


这篇关于如何在没有cookie的情况下在PHP / JS中创建计数器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆