阿贾克斯登录和JavaScript的饼干,这是安全的?这是、饼干、安全、阿贾克斯

2023-09-10 18:21:47 作者:爱玩ι之徒

我在做一个Ajax登录系统,我不知道这是否是安全的。

     后的用户名和阿贾克斯密码   检查登录服务器端,如果有效,返回新的会话ID和一个JSON字符串用户ID   获取JSON的JavaScript,然后创建会话的Cookie的session_id和user_ID的   拨打其中记录用户重定向与AJAX 页   

感谢

解决方案

安全为08/15网站:是 安全网上银行:没有

您使用的方法是等同于一个未加密的日常登录<形式取代。尽管你应该不依靠user_ID的饼干。而保存验证USER_ID仅在会话存储。

你也可以尝试只返回会话cookie的JSON结果的AJAX调用。它通常坚持所有进一步的HTTP请求,所以你不需要(3)通过Javascript另外设置cookie。

I'm making an Ajax login system and i wonder if this is secure

Post the username and the password with ajax Check the login server side, if valid, return the new session id and the user id in a JSON string Get the JSON with javascript then create the session's cookies "session_id" and "user_id" Call the page where the logged user is redirected with AJAX 欧冠之王 禁区之王 你真的以为C罗 只会吃饼不会做饼

Thanks

解决方案

Secure for 08/15 website: yes Secure for online banking: no

The method you use is equivalent to an unencrypted everyday login <form>. Albeit you should really not rely on a "user_id" cookie. Rather save the verified user_id in the session store only.

Also you might try to simply return the session cookie on the JSON result for the AJAX call. It usually sticks to all further HTTP requests, so you don't need (3) to set the cookie via Javascript additionally.