简体   繁体   English

我应该在我的网站上使用“登录”会话吗?

[英]Should I use sessions for “LOGINS” on my site?

I have a classifieds website, where anyone (no need for login currently) can post a classified. 我有一个分类广告网站,任何人(当前无需登录)都可以发布分类广告。 It is PHP based. 它基于PHP

The procedure for posting is currently like this: 当前的发布过程如下:

click on " New Classified " ---> 点击“ 新分类 ” --->
fill in a form of all information and hit " View classified before publishing it " ---> 填写所有信息的表格,然后单击“ 发布之前对其进行分类 ” --->
the form submits to a " verify classifieds " page, where users verify their inputs ---> 表单提交到“ 验证分类 ”页面,用户可以在其中验证输入--->
If everything is okay in the " verify " page, then the user hits OK and the classified is published . 如果“ 验证 ”页面中的一切正常,则用户单击“确定”并发布分类。

The above procedure isn't exactly optimized. 上面的过程并未完全优化。 The first page ( new_classified ) where the form is, is pretty good, but the second page ( verify ) uses x number of hidden inputs in another form , used to contain the previous pages form inputs . 表单所在的第一页( new_classified )很好,但是第二页( verify )在另一种表单中使用了x个隐藏输入 ,用于包含先前页面的表单输入

Now you know how it works on my site. 现在您知道了它如何在我的网站上工作。

The issue today is that alot of companies want to publish their classifieds, and alot of classifieds at the same time. 今天的问题是,许多公司希望同时发布其分类信息。 This means they have to fill out the form again and again currently. 这意味着他们必须当前一次又一次地填写表格。

I am thinking about creating a login , for companies only, so that their information is automatically inputted into the form, so all they would have to do is fill out the specific classified details like "headline" and "description" etc. 我正在考虑仅为公司创建一个登录名 ,以便将其信息自动输入到表单中,因此,他们要做的就是填写特定的分类详细信息,例如“标题”和“描述”等。

How should I do this in my case? 我该怎么办? Sessions ? 会议

This means I will have to create a new MySql table (I use MySql mainly) and store company-profiles there. 这意味着我将不得不创建一个新的MySql表 (我主要使用MySql)并在那里存储公司资料

So do you think converting to sessions is alot of work? 那么,您认为转换为会话是很多工作吗? Worth it? 值得? More reliable? 更可靠吗? I have never used sessions so I wouldn't know. 我从未使用过会话,所以我不知道。

As a last note, you should know that I use a picture upload tool on the first page of " new_classified ". 最后一点,您应该知道我在“ new_classified ”的第一页上使用了图片上传工具。 When a user choses a file to upload, the page is automatically * refreshed *, and then the image is displayed on the same page under section "images uploaded". 当用户选择要上传的文件时,页面会自动 * 刷新 *,然后图像显示在同一页面的 “图像上传”部分下。 I hope the session wont interfere with this approach. 我希望会议不会干扰这种方法。

Thanks 谢谢

I think it is worth your while to do logins, and even on a very basic level it will help you to identify who is using your site etc. 我认为值得您花时间进行登录,即使是在非常基本的级别上,它也将帮助您确定谁在使用您的网站等。

This is probably a big debate around developers, what is the best way to do a good login system, whether it's basic or not doesn't matter, I think the concepts still stay the same. 这可能是围绕开发人员的一场大辩论,建立一个好的登录系统的最佳方法是什么,不管是基本的还是无关紧要的,我认为这些概念仍然保持不变。

In your case I would suggest session cookies along with a login table consisting of user details. 在您的情况下,我建议会话cookie以及由用户详细信息组成的登录表。 This would help you to verify the user on more than one occasion during his/her visit to the site. 这将帮助您在访问网站期间多次验证用户。

A login is checked against a user entry in a table and then a session cookie is created. 将对照表中的用户条目检查登录名,然后创建会话cookie。 This session you can choose to never expire also. 您也可以选择永不过期。

You can then on every step check that the user is the user that is supposed to be logged in and get the companies details by checking the username. 然后,您可以在每一步上检查该用户是否为应该登录的用户,并通过检查用户名来获取公司详细信息。 This would make for a better query in my opinion. 我认为这将使查询更好。

Sessions aren't a lot of work and it's relatively easy to learn. 会议不是很多工作,而且相对容易学习。 http://www.php.net/manual/en/book.session.php http://www.php.net/manual/zh/book.session.php

http://www.9lessons.info/2010/02/php-login-script-with-encryption.html is a good example of what you can do with this. http://www.9lessons.info/2010/02/php-login-script-with-encryption.html是您可以执行此操作的一个很好的示例。 Have a look around still. 仍然环顾四周。 There are a bunch of these great tutorials on the web. 网络上有很多很棒的教程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM