English 中文(简体)
创造我的记忆
原标题:Creating a remember me function

i 在我的标识页上有一个免责标语,在被点击时,我想打上标语。

该网站是javascript/jquery php,然后书写并储存在数据库中,因此可以检索,但现在需要将用户与这一浮式数据库价值联系起来。

因此,正如浏览器一样,或者说需要打 co或做些什么,任何人都能够向我说明如何最好地做到这一点?

最佳回答

这样做的共同和更为基本的方法是与用户名书写 co,另一种是写上 ha的密码。 但是,我认为你应该用PHP书写 co,而联合材料是一种客户语言,因此,例如,你可以躲藏你的盐类。

问题回答

So i need like a browser id, or i need to set a cookie or something, can anyone advise me as to the best way top go about this?

由于没有[unique]browser id 或“有点”你必须戴上 co。

PHP中的使用 co,使用j Query指PHP的文字。

jQuery:

$("#tick-me").live("click", function(){
    $.get("remember.php", function(data) {
        if ( data ==  OK  ){
             // Success, do something...
        } else {
             // Failure, do something...
        }
    });
});

之后是 remember。 php:

<?php
setcookie(  remember_me , true, time()+(3600*24*7) ); // Remember for 7 days
echo  OK ;

In your HTML form:

<input type="checkbox" name="remember" <?php if ( isset($_COOKIE[ remember_me ]) ) echo  checked="checked"; ?> />

http://plugins.jquery.com/project/Cookie”rel=“nofollow”

You can use the cookie to store values between the sessions however if you are saying that you have a database that stores the state of the check box, then I suppose all you need is to store some identification to know to whom the record belongs.

  • If your user s login then it s easy because you use their userid with your check box status
  • If the do not login then its more complicated:
    • you can store a cookie with user id on the user s computer (what is users use different computers?)
    • you can recognize users by their IP (flawed in a sense that there may be many users behind same IP via NAT
    • Make them login :)

如果你想要利用数据库+厨师或把所有信息储存在厨师中,或把所有信息储存在数据库中,我会向你们提出。 铭记在用户之间真正辨别的唯一真正办法是使用户的标识化,因为现在的居住者拥有更多的网络接入点(家庭、工作、iPad、p),如果你利用厨师或IP地址来发现他们,他们就不会有自己的环境。

你们可以通过 co子实现。

setcookie(  remember_me , true);

接下来,当用户开放网站时,可以安装 co子,如果使用“COOKIE[记住_me]美元的条件,你可以有条件选择相应的检查箱。





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签