Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^2: perl as a php alternative

by iaw4 (Monk)
on Dec 06, 2015 at 17:58 UTC ( [id://1149524]=note: print w/replies, xml ) Need Help??


in reply to Re: perl as a php alternative
in thread perl as a php alternative

I am going to investigate Mason and Mojolicious Lite. Do they have built-in first-class session support? In file1.php
<?php session_start(); $_SESSION['hello']=23; ?>
and in file2.php
<?php session_start(); echo $_SESSION['hello']; ?>
does exactly what one expects, as long as the browser remains the same. php nicely takes care of sending a random cookie at the right time of the http protocol, and stores the 'hello' variable in the thereby-named disk file on the server. I know I can write this myself, but this reinvents a painful wheel. transparent variable persistence across different webpages is quite nice.

there? not there?

Replies are listed 'Best First'.
Re^3: perl as a php alternative
by Your Mother (Archbishop) on Dec 06, 2015 at 22:16 UTC

    I did say that they all (all major Perl web frameworks) have sessions; and not only that but they are more secure without trying in Mojo and entirely configurable in a case like Catalyst so you can do sessions without cookies if necessary and keep the data on the backend in several different ways without any need for a database, again if necessary or preferable. I feel like you are intentionally reading my comments lightly. :|

    I also said if you want to use Mason because you like embedded code, you might as well stick with PHP. There will be no practical difference in what you do if that is the style you like and deployment will be harder with Perl than host default PHP. I should re-emphasize code embedded templates (meaning, controllers and models are all embedded in the view) is a mess for any serious project and it might come off snooty but it's not meant to be: I do not know any devs I consider serious or competent who write Perl this way. If you try to write it that way, you might end up blaming Perl for giving you the rope and moving on to Python or Ruby next because they force better practices in this domain.

    I want to repeat learning curve. Catalyst in particular is quite hard to learn because it has so much it can do. Once a site is done though, adding features, changing things, testing (Mojo has really good testing too and Dancer is well-liked though I don't use it), all becomes extremely easy and make painting yourself into codebase corners less likely.

Re^3: perl as a php alternative
by choroba (Cardinal) on Dec 06, 2015 at 20:12 UTC
    In Dancer, you can do
    session hello => 42;

    and later

    my $hello = session 'hello';

    In config.yml, you can specify what kind of session storage you want to use: simple, cookie, storable, or YAML. The later ones are persistent.

    ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (3)
As of 2024-03-29 06:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found