可以在客户端更改$

编程入门 行业动态 更新时间:2024-10-07 15:18:38
本文介绍了可以在客户端更改$ _SESSION变量吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

可能重复: PHP客户可以设置$ _SESSION变量吗?

Possible Duplicate: PHP Can a client ever set $_SESSION variables?

我想知道的是,PHP $ _SESSION变量是否可以在客户端更改.例如,如果我这样做了$_SESSION['username'] = $username;有人可以以某种方式更改我的$_SESSION['username']变量的值吗?

What I'd like to know, is whether a PHP $_SESSION variable can be changed on the client-side. If, for example, I do $_SESSION['username'] = $username; Can someone somehow change the value of my $_SESSION['username'] variable?

推荐答案

PHP是服务器端编程语言,并且$ _SESSION超全局变量只能在服务器上直接访问.通过普通" php会话,包含在SESSON超全局变量中的数据将以cookie的形式在浏览器和服务器之间来回传递.因此,从技术上讲,可以通过修改Cookie在Web浏览器中使用Javascript修改会话.

PHP is a server-side programming language and the $_SESSION superglobal is only directly accessible on the server. With 'normal' php sessions, the data contained in the SESSON superglobal is passed back and forth between the browser and the server in a cookie. So technically, it is possible to modify the session with Javascript in a web browser by modifying the cookie.

但是请注意,任何尝试做这种事情的想法都可能是一个可怕的主意,并且很可能有一种更简单的方法来完成您想要做的事情.

But please note, any attempt to do anything like this is probably a terrible idea and there's most likely a far more simple way to accomplish whatever you're trying to do.

我问的这个问题可能对您有用 Codeigniter/PHP会话安全性问题

This question I asked may be of use to you Codeigniter/PHP sessions security question

更多推荐

可以在客户端更改$

本文发布于:2023-11-13 02:45:07,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1583210.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:客户端

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!