关于session会话的有关问题 php
关于session会话的问题 php
本帖最后由 redenn 于 2012-11-11 15:37:21 编辑
今天看了关于session的视频。 那位老师说,当浏览器访问服务端的时候创建一次会话。 然后 php页面中session_start在服务器创建了一个
session_id,它把session_id以cookie的方式返回给浏览器。浏览器cookie带着这个id去访问其它的页面,从而能找到服务器端的这个id对应
的session文件,从而执行数据交流。
但,有一些问题不明白:
1.服务器把session_id传递给浏览器的cookie,这个cookie是不是在浏览器客户端的默认cookie文件夹里确实存在的呢,存在的时间又是多少
呢?
2.当我访问网站时如何能确确实实地得到 那个session_start为我准备的会话的session_id。和其中中的内容。
3. 通过这个session_id如何实现,curl模拟登陆呢?
希望各位好心的朋友,能为我解惑啊,或给我一些思路。
------解决方案--------------------
1、session_id 存在于浏览器搜使用的内存里,而不是对应的cookie文件中。因为session_id的生存时间是浏览器打开期间,而cookie文件是在浏览器关闭时才创建,用于保存尚未过期的cookie变量
2、session_start 后,你可以用 session_id 函数获取当前的 session_id,用 $_SESSION 数组管理 session 变量
3、不是通过 session_id 模拟登陆,而是通过 cookie 模拟登陆
curl 提供了
CURLOPT_COOKIE 发送 cookie 变量
CURLOPT_COOKIEFILE 发送 cookie 文件
CURLOPT_COOKIEJAR 接收 cookie 到文件
------解决方案--------------------
1.session的生存时间不是1440秒(24分钟)么,而且浏览器禁用了cookie,则session_start()生成的session_id对于浏览器的操作都会无效。所以session_id不是与cookie有关么?
2.因为我是想访问别人的网站, 然后得到我访问中别人网站的session_start()产生的session_id,这怎么获得。
3.因为,许多网站都是以session做为身份验证,而我用cookie就无效了。所以想以session_id所对应的文件里的内容,作为模拟登陆的验证。
------解决方案--------------------
该回复于2012-12-08 14:13:03被管理员删除

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











If you find event ID 55, 50, 140 or 98 in the Event Viewer of Windows 11/10, or encounter an error that the disk file system structure is damaged and cannot be used, please follow the guide below to resolve the issue. What does Event 55, File system structure on disk corrupted and unusable mean? At session 55, the file system structure on the Ntfs disk is corrupted and unusable. Please run the chkMSK utility on the volume. When NTFS is unable to write data to the transaction log, an error with event ID 55 is triggered, which will cause NTFS to fail to complete the operation unable to write the transaction data. This error usually occurs when the file system is corrupted, possibly due to the presence of bad sectors on the disk or the file system's inadequacy of the disk subsystem.

When logging into iTunesStore using AppleID, this error saying "This AppleID has not been used in iTunesStore" may be thrown on the screen. There are no error messages to worry about, you can fix them by following these solution sets. Fix 1 – Change Shipping Address The main reason why this prompt appears in iTunes Store is that you don’t have the correct address in your AppleID profile. Step 1 – First, open iPhone Settings on your iPhone. Step 2 – AppleID should be on top of all other settings. So, open it. Step 3 – Once there, open the “Payment & Shipping” option. Step 4 – Verify your access using Face ID. step

Screen brightness is an integral part of using modern computing devices, especially when you look at the screen for long periods of time. It helps you reduce eye strain, improve legibility, and view content easily and efficiently. However, depending on your settings, it can sometimes be difficult to manage brightness, especially on Windows 11 with the new UI changes. If you're having trouble adjusting brightness, here are all the ways to manage brightness on Windows 11. How to Change Brightness on Windows 11 [10 Ways Explained] Single monitor users can use the following methods to adjust brightness on Windows 11. This includes desktop systems using a single monitor as well as laptops. let's start. Method 1: Use the Action Center The Action Center is accessible

The famous activation script MAS2.2 version supports digital activation again. The method originated from @asdcorp and the team. The MAS author calls it HWID2. Download gatherosstate.exe (not original, modified) from https://github.com/massgravel/Microsoft-Activation-Scripts, run it with parameters, and generate GenuineTicket.xml. First take a look at the original method: gatherosstate.exePfn=xxxxxxx;DownlevelGenuineState=1 and then compare with the latest method: gatheros

In iOS 17, Apple introduced several new privacy and security features to its mobile operating system, one of which is the ability to require two-step authentication for private browsing tabs in Safari. Here's how it works and how to turn it off. On an iPhone or iPad running iOS 17 or iPadOS 17, Apple's browser now requires Face ID/Touch ID authentication or a passcode if you have any Private Browsing tab open in Safari and then exit the session or app to access them again. In other words, if someone gets their hands on your iPhone or iPad while it's unlocked, they still won't be able to view your privacy without knowing your passcode

In Alibaba software, once you successfully register an account, the system will assign you a unique ID, which will serve as your identity on the platform. But for many users, they want to query their ID, but don't know how to do it. Then the editor of this website will bring you detailed introduction to the strategy steps below. I hope it can help you! Where can I find the answer to Alibaba ID: [Alibaba]-[My]. 1. First open the Alibaba software. After entering the homepage, we need to click [My] in the lower right corner; 2. Then after coming to the My page, we can see [id] at the top of the page; Alibaba Is the ID the same as Taobao? Alibaba ID and Taobao ID are different, but the two

Cookies are usually stored in the cookie folder of the browser. Cookie files in the browser are usually stored in binary or SQLite format. If you open the cookie file directly, you may see some garbled or unreadable content, so it is best to use Use the cookie management interface provided by your browser to view and manage cookies.

Cookies on your computer are stored in specific locations on your browser, depending on the browser and operating system used: 1. Google Chrome, stored in C:\Users\YourUsername\AppData\Local\Google\Chrome\User Data\Default \Cookies etc.
