Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: PHP Sessions and Perl

by marto (Cardinal)
on Mar 16, 2021 at 17:12 UTC ( [id://11129775]=note: print w/replies, xml ) Need Help??


in reply to SOLVED! PHP Sessions and Perl

This isn't a use case for CGI::Lite, you aren't running a CGI script here. Consider the following:

#!/usr/bin/perl use WWW::Mechanize; use strict; use warnings; my $browser = WWW::Mechanize->new(); my $response = $browser->get('https://archive.org'); my $cookie_jar = $browser->cookie_jar(HTTP::Cookies->new()); $cookie_jar->extract_cookies( $response ); my $cookie_content = $cookie_jar->as_string; print $cookie_content;

Prints:

Set-Cookie3: PHPSESSID=ls6vbb4cqpeord3o1g96hmacg6; path="/"; domain=ar +chive.org; path_spec; discard; version=0 Set-Cookie3: abtest-identifier=ba42ec4d4af62f23e1645b2597f22eec; path= +"/"; domain=archive.org; path_spec; expires="2022-03-16 16:35:57Z"; v +ersion=0 Set-Cookie3: donation-identifier=d3bd1e3bebfa0105babd7b9ca4a9b5c4; pat +h="/"; domain=archive.org; path_spec; expires="2022-03-16 16:35:57Z"; + version=0

Replies are listed 'Best First'.
Re^2: PHP Sessions and Perl
by bajangerry (Sexton) on Mar 16, 2021 at 17:41 UTC
    Hi Marto, I may be getting confused with the difference between sessions and cookies, can you confirm for me that I will have access to ALL of the session parameters by using a cookie? What I mean is, the session information in the webpage provide information such as username and session ID to following webpages if you are browsing with Chrome etc, are these accessible to Perl scripts in the same way using the cookies?

      You're confusion server side sessions and cookies. I think you need to read the comments of your php code:

      // Create sessions so we know the user is logged in, they basically ac +t like cookies but remember the data on the server.
        Ok, I am aware that sessions are stored on the server side, my confusion is how to access that information in Perl to use it for authorizing access to other pages.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11129775]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2024-03-28 09:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found