Hi!
I've got an unusual problem here. I'm trying to write a PHP script that
behaves like a web client. Why? I want to automatically check specific
URLs for changes.
I'm using file_get_conten ts(URL) to read the pages and this seems to
work just fine as long as there are no logins, sessions or cookies.
But I'm getting a new PHPSESSID from the site whenever I get a new page
(or refresh the same page) even though I did a login through the URL
(...login.php?u ser=...&pass=.. .) and it seemed to work. So the login
does not really work.
So what do I have to do to make the login stick? Use a different way to
read the pages? Work with sessions? Cookies?
Don't forget that the script is not running on a server, it is the
client! I have not found any documentation for this rare case.
I'm curious if any of the PHP pros out there knows an answer to this
problem. If anyone does, an answer would be appreciated. Thanks in
advance. 6 3119
Anonymous <an*******@nowh ere.invalid> wrote:
[php client] So what do I have to do to make the login stick? Use a different way to read the pages? Work with sessions? Cookies?
You should use a different way to request URLs. How are you requesting
them now? fopen? There are many intelligent ways to implement scripts
that pretend to be http clients. curl might be available on your
machine. Else there are classes like snoopy or the httpclient class in
PEAR. These will make handling cookies easier...
--
Daniel Tryba
Hi,
Are you passing the PHPSESSID back to the server in your URLs?
Kelvin
"Anonymous" <an*******@nowh ere.invalid> wrote in message
news:41******** *******@nowhere .invalid: Hi!
I've got an unusual problem here. I'm trying to write a PHP script that behaves like a web client. Why? I want to automatically check specific URLs for changes.
I'm using file_get_conten ts(URL) to read the pages and this seems to work just fine as long as there are no logins, sessions or cookies.
But I'm getting a new PHPSESSID from the site whenever I get a new page (or refresh the same page) even though I did a login through the URL (...login.php?u ser=...&pass=.. .) and it seemed to work. So the login does not really work.
So what do I have to do to make the login stick? Use a different way to read the pages? Work with sessions? Cookies?
Don't forget that the script is not running on a server, it is the client! I have not found any documentation for this rare case.
I'm curious if any of the PHP pros out there knows an answer to this problem. If anyone does, an answer would be appreciated. Thanks in advance.
---
Mail is certified Virus Free.
Checked by AVG anti-virus system ( http://www.grisoft.com).
Version: 6.0.773 / Virus Database: 520 - Release Date: 05/10/2004
Anonymous wrote: I've got an unusual problem here. I'm trying to write a PHP script that behaves like a web client. Why? I want to automatically check specific URLs for changes.
I'm using file_get_conten ts(URL) to read the pages and this seems to work just fine as long as there are no logins, sessions or cookies.
But I'm getting a new PHPSESSID from the site whenever I get a new page (or refresh the same page) even though I did a login through the URL (...login.php?u ser=...&pass=.. .) and it seemed to work. So the login does not really work.
So what do I have to do to make the login stick? Use a different way to read the pages? Work with sessions? Cookies?
I did this a couple times using fsockopen (though I hear CURL is good),
extracted the cookie information, and resent the cookie info with each request.
Read the manual and especially the comments for fsockopen. You may find you
need to send some other, custom headers (notably user agent) for some sites, as
the default settings may be interpreted as spambots.
Shawn
--
Shawn Wilson sh***@glassgian t.com http://www.glassgiant.com
Daniel Tryba wrote: Anonymous <an*******@nowh ere.invalid> wrote: [php client] So what do I have to do to make the login stick? Use a different way to read the pages? Work with sessions? Cookies? You should use a different way to request URLs. How are you requesting them now? fopen? There are many intelligent ways to implement scripts
As I already wrote I'm using file_get_conten ts(URL).
that pretend to be http clients. curl might be available on your machine. Else there are classes like snoopy or the httpclient class in PEAR. These will make handling cookies easier...
What is PEAR?
Kelvin Mackay wrote: Are you passing the PHPSESSID back to the server in your URLs?
No. I have already thought of that trick but it doesn't work.
Shawn Wilson wrote: So what do I have to do to make the login stick? Use a different way to read the pages? Work with sessions? Cookies?
I did this a couple times using fsockopen (though I hear CURL is good), extracted the cookie information, and resent the cookie info with each request. Read the manual and especially the comments for fsockopen. You may find you need to send some other, custom headers (notably user agent) for some sites, as the default settings may be interpreted as spambots.
Could you please elaborate on that?
What is CURL?
Could you give me some lines of sample code how to request and store a
page in a string variable with fsockopen? Which custom headers do you
think are required and how do I send them?
Thanks. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: windandwaves |
last post by:
Hi Gurus
I am basically sorry that I have to bother you about this. I am a PHP
beginner and I have been studying sessions and cookies over the last few
weeks. I have learned lots, but I am missing the big picture.
Is it like this:
1. user comes to site
2. user does something (e.g. a search) that may be useful later => session
|
by: Simon Faulkner |
last post by:
I have written a small Python web database which was initially just
used in house.
Now we want people to be able to read some pages from outside so I
need to implement some sort of security.
Does Python have sessions like PHP?
If not should I roll my own from a cookie and a MySQL table?
|
by: JJ |
last post by:
Hi,
I really need to use cookieless ASP sessions with ASP 3 (IIS5)
Can I find out the session ID from the first page, then post it or send it
with the url to the next page, then at the start of the next page asp, set
the session ID from the value retrieved from the URL?
How do you manually set the session ID?
|
by: Sidd |
last post by:
Hi,
I tried finding and example of multithreaded client-serve program in
python. Can any one please tell me how to write a multithreaded
client-server programn in python such that
1.It can handle multiple connections
2.It uses actual threads and not select() or some other function
|
by: Steve Franks |
last post by:
According to the docs you tell ASP.NET to use cookieless sessions by setting
a value in the config.web file.
However, what if I wanted to determine at run time whether or not I wanted
to use cookieless sessions for a particular user, and if so, I'd instruct
ASP.NET to turn on cookieless sessions for a particular user session. Is
this possible?
For example I want to use cookie based sessions by default for all users.
But if a user has...
| |
by: Chris Mahoney |
last post by:
Hi
I'm using several Sessions in my app. When the user has cookies enabled in
their browser, everything works fine. But with cookies disabled, only IE
seems to remember the sessions. In Firefox and Safari, the session values
seem to be "forgotten".
I've looked around on Google but can't find any solutions to this problem.
Plus I don't know how debug with Firefox (eg. step through the code).
|
by: Atte André Jensen |
last post by:
Hi
I'm developing a site where I'd like to store information during a users
visit. So far I've been using sessions, but as far as I can tell it's
not possible to control for how long a session is valid. It seems that
these information are valid until the browser closes.
On the other hand it's possible to set expiration time for cookies.
Does this mean that I have to abanbon $_SESSION altogether and switch to
|
by: Marc Gravell |
last post by:
Kind of an open question on best-practice for smart-client design. I'd
really appreciate anyones views (preferably with reasoning, but I'll take
what I get...). Or if anybody has any useful links on the subject? (and yes,
I have already googled it at length, but still no strong decision)
=============
After a long stint of pure-desktop / pure-server applications, I'm currently
working on a number of smart-client projects in C# using...
|
by: Zorque |
last post by:
Suppose I have an HTML form that sends data to a PHP script, "post"
method.
If this script generates a page with a link to another script, will the
latter script get the former's $_POST data when the user clicks on the
link?
If not, is there a straightforward way (i.e.: no saving to files or
cookies) to "post" the data to the latter script without using a form?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |