Storable.pm & data insertion
I am using perl & Apache::Session on my web app for almost everything but there is one function that I decided to write in PHP. Unfortunately, I need access to the session. So I wrote a read & a write perl script as intermediaries so I can read and modify the session. The read works great, but the write doesn't.
I convert the data with nfreeze, store it in the database. As a check, I then retrieve it and thaw it, part of the object is lost. When I check the database row, the data is definitely not all there. When I nfreeze and thaw without putting into the database, the object remains intact. I have tried using params and not. I set name 'utf8', because Storable is supposed to be only utf8, as I understand it. Just in case, I have tried using the utf8::upgrade and utf8::downgrade but get the "Magic number checking on storable string failed" error so that doesn't work too well. When I print out the sql and put it directly into the database with phpmyadmin, it goes in fine. Funny thing, is I haven't had any problems with Apache::Session.
Command:
perl /var/www/www.shareyoursnapshots.com/scripts/session_write.ps '8a32874ec44403b8472e87d1a000714' 'a:5:{s:11:"_session_id";s:32:"8a32874ec44403b8472e87d1a0300714";s:4:"user";s:17:"greanie@yahoo.com";s:7:"user_id";i:1;s:4:"role";s:6:"member";s:14:"UPLOAD_SESS_ID";s:32:"2b047be6ffc595d3cedcb120500c1827";}'
a:5:{s:11:"_session_id";s:32:"8a32874ec44403b8472e87d1a0300714";s:4:"user";s:17:"greanie@yahoo.com";s:7:"user_id";i:1;s:4:"role";s:6:"member";s:14:"UPLOAD_SESS_ID";s:32:"2b047be6ffc595d3cedcb120500c1827";}
Data becomes:
$ref = {
'_session_id' => '8a32874ec44403b8472e87d1a0300714',
'UPLOAD_SESS_ID' => '2b047be6ffc595d3cedcb120500c1827',
'user_id' => 1
};
Then nfreeze turns ref into
$data = '
8a32874ec44403b8472e87d1a0300714_session_id
2b047be6ffc595d3cedcb120500c1827UPLOAD_SESS_Iuser_id';
SQL is:
UPDATE
sessions
SET
a_session = '
8a32874ec44403b8472e87d1a0300714_session_id
2b047be6ffc595d3cedcb120500c1827UPLOAD_SESS_Iuser_id'
WHERE
id LIKE '8a32874ec44403b8472e87d1a000714'
As retrieved from database:
8a32874ec44403b8472e87d1a0300714_session_id
2b047be6ffc595d3cedcb120500c1827UPLOAD_SESS_ID
And finally thawed into:
$data2 = undef;
System:
Linux Gentoo 2006.0
MySQL Ver 14.12 Distrib 5.0.44, for pc-linux-gnu (i686) using readline 5.1
Any ideas??
Subject
Written By
Posted
Storable.pm & data insertion
February 02, 2008 06:07PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.