English 中文(简体)
php 在标识后选择成员
原标题:php optimising members after login
  • 时间:2011-08-01 06:58:58
  •  标签:
  • php
  • cookies

在创建我的网站时,我被 st。

我们应使用<代码>_COOKIE或会议。

我想使用<代码>_COOKIE美元更好。

但是,应当把用户名或用户独一无二的贴现储存起来吗?

以及投入多少时间,应当把 co子的时间推到来?

在每一页或不同页上应当同时进行? 如果情况不同,数量如何?

最佳回答

It ultimately comes down to whether your website/application needs to be stateless or not. (See Webservices are stateless?). Its mostly a design decision, but I prefer stateless applications where possible.

如果你在座使用厨师,那就有些ti:

  • You want to store data in the cookie that will uniquely identify the user, but something that is not able to be guessed.
  • It is common to put a user_id or a username (provided the user is unable to change it) and a random hash stored alongside the row in the database. When it comes to logging a user in load the user by their user_id and check that the hash in the cookie matches the one in the database.
  • As far as how long to store it for, that depends on the nature of your application. If it contains sensitive information then its probably not a good idea to make it last for a long time. You should update the time each time the users requests a page so if a user is using the site they will remain logged in for the duration of their visit.

确实重要的是,不要将敏感信息放在厨师身上,因为这些信息储存在用户计算机的便衣中。

问题回答

您没有提供有关你选择数据基数的理由的任何信息,也没有说明你试图达到什么目标(“在标识后选择成员”是毫无意义的。

要么使用_COOKIE美元或会议。

很多数据是你试图储存的? 时间如何? 如果没有会议,你是否需要获得机会? 如果是,数据是否有必要提供? 用户将数据从网站更改有何影响?

But what should i store in cookie the users username or the user s unique id ?

如果贵网站认为在厨师身上有这种说法,那么对贵场址的 ha弄就像改变ok价值一样简单。





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签