如何不允许不登录的用户发表评论? [英] How to not allow not logged in user to comment ?

查看:103
本文介绍了如何不允许不登录的用户发表评论?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我的网站上有评论功能,我只希望登录的用户对此发表评论,我该怎么做?我已经知道如何拒绝对页面的访问,是否也可以通过相同的方式完成?

在此先感谢您.

Hi all ,

I have a comment functionality on my website and i want only logged in users to comment on it so how can i do it ? I already know how to deny access to pages so is it done in the same way ?

Thanks in advance.

推荐答案

,您可以为此目的使用会话.用户登录时将其存储在会话中,并在用户注销时将其删除.
将您的评论控件放在面板中,默认情况下将其可见性设置为隐藏.在您的包含评论控件的页面中,如果会话不为null,则只需检查页面加载即可打开可见性.否则它将保持隐藏状态.
you can use sessions for this purpose. store the user id in session when a user logged in and delete it when he logged out.
put your comment control in a panel and by default set its visibility hidden. In your page which contain the comments control just check in the page load if session is not null turn visibility visible. otherwise it remains hidden.


这篇关于如何不允许不登录的用户发表评论?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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