Mailing List Archive

Don't use session hashes
On Mon, 21 Dec 2020 12:15:45 +0000
James Smith <js5@sanger.ac.uk> wrote:

Hi James,

>
> The first rule of session hashes is don't use session hashes,

I thought this was a standard way of storing user information? I've copied an example at the bottom (this application calculates quotes for a sailmaker)

I'm not sure what else I could use?

>but the 2nd rule of session hashes is don't write them to disk - that is really inefficient. Look at using something like MySQL,

Actually, I serialize the data and store it into a Postgresql table. This is what I meant by writing to disk. I suppose some caching by Postgresql helps here?

> memcached, redis, ... to >store them instead - whatever you do - just avoid writing to disk!

I'll have a look, thanks


$VAR1 = {
'dump' => 1,
'base_currency' => 'EUR',
'username' => 'franck-bob@orange.fr',
'_session_id' => 'Yd7Oif8hi7Xb91cyoGVK3nS7WkEEt4d0',
'devis' => {
'type_bateau' => '630 Q',
'variante_for' => undef,
'margin_rate_localized' => '',
'option' => {
'clew_block_cost_localized' => ' 0,00',
'lattes_forcees' => '2',
'lattes_cost' => '44.4570000000000000000000',
'ris' => '2',
'boom_cover_cost' => '0',
'clew_block_unit_price' => '0',
'overhead_leech_line_cost' => '0',
'bande_anti_uv_cost' => '0',
'lattes_cost_localized' => '44,46',
'bande_anti_uv_cost_localized' => '0',
'clew_block' => 'Aucun',
'chariot_unit_price' => '0',
'cunningham' => 'False',
'cunningham_cost_localized' => '0',
'luff_foam_cost' => '0',
'boom_cover_cost_localized' => '0',
'luff_foam_cost_localized' => '0',
'boom_cover' => 'False',
'ris_cost_localized' => '240,00',
'protection' => 'Aucune',
'total_option_cost_localized' => '379,07',
'two_ply_leech_cost' => '94.613675',
'cunningham_cost' => '0',
'clew_block_cost' => '0',
'boitier_chute' => 'Standard',
'ris_chute' => 'Poulie small',
'batten_shape' => 'ORC VINYLESTER',
'two_ply_leech_cost_localized' => '94,61',
'bande_anti_uv' => 'Aucune',
'batten_shape_unit_price' => '5.00',
'boitier_guindant_unit_price' => '0.00',
'total_option_cost' => '379.07',
'ris_guindant' => 'Antal small',
'luff_foam' => 'False',
'bande_anti_uv_unit_price' => '0',
'two_ply_leech' => 'True',
'ris_cost' => '240.00',
'lattes_flottantes' => '2',
'ris_chute_unit_price' => '40.00',
'chariot' => 'Aucun',
'overhead_leech_line_cost_localized' => '0',
'boitier_chute_unit_price' => '0',
'overhead_leech_line' => 'True',
'ris_guindant_unit_price' => '25.00',
'enrouleur' => 'True',
'boitier_guindant' => 'Velcro'
},
'info_tissu' => {
'description' => '6,68 - 6,2 OZ - 268 g/sqm',
'prix_localized' => '32,71',
'remise' => '0.1',
'tissu_cost_localized' => '378,45',
'oz' => '6.20',
'oz_adjust' => 0,
'nom_tissu' => 'Challenge Fastnet Offshore',
'oz_localized' => '6,20',
'prix' => '32.71',
'tissu_cost' => '378.4547',
'max_length' => '7.50',
'oz_retenu_localized' => '7,00',
'short_spiel' => 'Le dacron le plus durable pour ceux qui voyagent loin'
},
'correction' => '0',
'notes' => '',
'cost' => {
'hors_taxe' => '719,77',
'transport_fee' => '102,27',
'margin_amount' => '0,00',
'tva' => '143,95',
'global_cost' => '878,12',
'ttc' => '863,72',
'global_cost_converted' => '719,77',
'toll_rate' => '94,08'
},
'genre_voile' => 'Grand-voile',
'nom_finition' => 'Grand Large Fastnet',
'nom_voile' => 'Grand-voile',
'info_bateau' => {
'longueur_bateau_localized' => '6,30',
'e_main_foot_localized' => '2,90',
'p_main_luff_localized' => '7,00',
'certified_area_localized' => '11,07',
'coefficient' => '0.57',
'longueur_bateau' => '6.30',
'computed_area_localized' => '11,57',
'certified_area_verified' => 'f',
'e_main_foot' => '2.90',
'p_main_luff' => '7.00',
'default_computed_area' => '11.57',
'coefficient_localized' => '0,57',
'computed_area' => '11.57',
'form_option' => 'Standard',
'default_computed_area_localized' => '11,57'
},
'delivery_zone' => '1',
'forme_voile' => 'Voile plate',
'id_devis' => '95',
'id_prospect' => '290',
'nom_prospect' => "Sylvie Andr\x{e9}",
'exchange_rate_localized' => '1,22'
},
'exchange_rate_localized' => '1,23'
};
RE: Don't use session hashes [EXT] [ In reply to ]
What I'm trying to say - yes use session IDs if you need to - but don't if you don't I see lots of PHP sites which create sessions for every visitor - and this tends to create a mass of 1 page sessions that never ever get used. So you should only create them on the first instance that you need to. Use you can create session IDs if you want to - but don't write to the database unless you have to...

If you need personalisation {UI tweaks} - store it directly in a cookie {you can sign it if you want for security reasons} - e.g only create a proper session if the user is logging in - or creating a "shopping cart" {in the loosest terms}. It take a huge load off the file system / database.


-----Original Message-----
From: Vincent Veyron <vv.lists@wanadoo.fr>
Sent: 21 December 2020 13:51
To: modperl@perl.apache.org
Cc: James Smith <js5@sanger.ac.uk>
Subject: Don't use session hashes [EXT]

On Mon, 21 Dec 2020 12:15:45 +0000
James Smith <js5@sanger.ac.uk> wrote:

Hi James,

>
> The first rule of session hashes is don't use session hashes,

I thought this was a standard way of storing user information? I've copied an example at the bottom (this application calculates quotes for a sailmaker)

I'm not sure what else I could use?

>but the 2nd rule of session hashes is don't write them to disk - that is really inefficient. Look at using something like MySQL,

Actually, I serialize the data and store it into a Postgresql table. This is what I meant by writing to disk. I suppose some caching by Postgresql helps here?

> memcached, redis, ... to >store them instead - whatever you do - just avoid writing to disk!

I'll have a look, thanks


$VAR1 = {
'dump' => 1,
'base_currency' => 'EUR',
'username' => 'franck-bob@orange.fr',
'_session_id' => 'Yd7Oif8hi7Xb91cyoGVK3nS7WkEEt4d0',
'devis' => {
'type_bateau' => '630 Q',
'variante_for' => undef,
'margin_rate_localized' => '',
'option' => {
'clew_block_cost_localized' => ' 0,00',
'lattes_forcees' => '2',
'lattes_cost' => '44.4570000000000000000000',
'ris' => '2',
'boom_cover_cost' => '0',
'clew_block_unit_price' => '0',
'overhead_leech_line_cost' => '0',
'bande_anti_uv_cost' => '0',
'lattes_cost_localized' => '44,46',
'bande_anti_uv_cost_localized' => '0',
'clew_block' => 'Aucun',
'chariot_unit_price' => '0',
'cunningham' => 'False',
'cunningham_cost_localized' => '0',
'luff_foam_cost' => '0',
'boom_cover_cost_localized' => '0',
'luff_foam_cost_localized' => '0',
'boom_cover' => 'False',
'ris_cost_localized' => '240,00',
'protection' => 'Aucune',
'total_option_cost_localized' => '379,07',
'two_ply_leech_cost' => '94.613675',
'cunningham_cost' => '0',
'clew_block_cost' => '0',
'boitier_chute' => 'Standard',
'ris_chute' => 'Poulie small',
'batten_shape' => 'ORC VINYLESTER',
'two_ply_leech_cost_localized' => '94,61',
'bande_anti_uv' => 'Aucune',
'batten_shape_unit_price' => '5.00',
'boitier_guindant_unit_price' => '0.00',
'total_option_cost' => '379.07',
'ris_guindant' => 'Antal small',
'luff_foam' => 'False',
'bande_anti_uv_unit_price' => '0',
'two_ply_leech' => 'True',
'ris_cost' => '240.00',
'lattes_flottantes' => '2',
'ris_chute_unit_price' => '40.00',
'chariot' => 'Aucun',
'overhead_leech_line_cost_localized' => '0',
'boitier_chute_unit_price' => '0',
'overhead_leech_line' => 'True',
'ris_guindant_unit_price' => '25.00',
'enrouleur' => 'True',
'boitier_guindant' => 'Velcro'
},
'info_tissu' => {
'description' => '6,68 - 6,2 OZ - 268 g/sqm',
'prix_localized' => '32,71',
'remise' => '0.1',
'tissu_cost_localized' => '378,45',
'oz' => '6.20',
'oz_adjust' => 0,
'nom_tissu' => 'Challenge Fastnet Offshore',
'oz_localized' => '6,20',
'prix' => '32.71',
'tissu_cost' => '378.4547',
'max_length' => '7.50',
'oz_retenu_localized' => '7,00',
'short_spiel' => 'Le dacron le plus durable pour ceux qui voyagent loin'
},
'correction' => '0',
'notes' => '',
'cost' => {
'hors_taxe' => '719,77',
'transport_fee' => '102,27',
'margin_amount' => '0,00',
'tva' => '143,95',
'global_cost' => '878,12',
'ttc' => '863,72',
'global_cost_converted' => '719,77',
'toll_rate' => '94,08'
},
'genre_voile' => 'Grand-voile',
'nom_finition' => 'Grand Large Fastnet',
'nom_voile' => 'Grand-voile',
'info_bateau' => {
'longueur_bateau_localized' => '6,30',
'e_main_foot_localized' => '2,90',
'p_main_luff_localized' => '7,00',
'certified_area_localized' => '11,07',
'coefficient' => '0.57',
'longueur_bateau' => '6.30',
'computed_area_localized' => '11,57',
'certified_area_verified' => 'f',
'e_main_foot' => '2.90',
'p_main_luff' => '7.00',
'default_computed_area' => '11.57',
'coefficient_localized' => '0,57',
'computed_area' => '11.57',
'form_option' => 'Standard',
'default_computed_area_localized' => '11,57'
},
'delivery_zone' => '1',
'forme_voile' => 'Voile plate',
'id_devis' => '95',
'id_prospect' => '290',
'nom_prospect' => "Sylvie Andr\x{e9}",
'exchange_rate_localized' => '1,22'
},
'exchange_rate_localized' => '1,23'
};


--
The Wellcome Sanger Institute is operated by Genome Research
Limited, a charity registered in England with number 1021457 and a
company registered in England with number 2742969, whose registered
office is 215 Euston Road, London, NW1 2BE.