ok, my problem is next:
i dont want to use session_start, i simply want to read content from file into $var, then i want to convert $var content into variables
1. $path_to_session_file = tmp\sessions\sess_dfc5c25b2f21a808c2e060fc0f878d8e
";
$f = file_get_contents($path_to_session_file);
if i make print_r($f);
if seee serialized content of session_variables
now i try to make unserialize on this var = $f but this dont helps.
can anybody something to advice to me ?????
thanks,.....
converting session data into variables
Moderator: General Moderators
-
Marco Polo I
- Forum Newbie
- Posts: 3
- Joined: Mon Oct 27, 2003 10:00 am
- Contact:
-
Marco Polo I
- Forum Newbie
- Posts: 3
- Joined: Mon Oct 27, 2003 10:00 am
- Contact:
...
1) here is my session
$fp = "C:\sess_041c46ab6c3e97f6bbcb7ec8de631ddb";
2) now i get all content of session file into string
$ff=file_get_contents($fp);
if i type print_r($ff); then i see this
mdat|a:5:{s:9:"fusername";s:8:"darconi8";s:9:"fmemberof";i:2;s:8:"fbannews";i:0;s:5:"fauth";i:1;s:8:"msession";s:32:"dinaburg49c1dc8d163decae1f471d8d";}url|s:3:"lp0";razdel|i:0;language|s:3:"rus";ovner|s:14:"VHALS-DINABURG";head|s:130:"";nomerlast|i:250;nomerprev|i:251;gdd|s:2:"21";gdm|s:1:"9";gdy|s:4:"2003";gazeta_date|s:25:"воскресение, 21 сентябрья";nomerlastdate|s:10:"09/21/2003";
3) now i try to unserialize this output
$ff = unserialize($ff);
var_dump($ff);
then if i type print_r($ff);
i see bool(false)
what this means ????
thanks for helping
$fp = "C:\sess_041c46ab6c3e97f6bbcb7ec8de631ddb";
2) now i get all content of session file into string
$ff=file_get_contents($fp);
if i type print_r($ff); then i see this
mdat|a:5:{s:9:"fusername";s:8:"darconi8";s:9:"fmemberof";i:2;s:8:"fbannews";i:0;s:5:"fauth";i:1;s:8:"msession";s:32:"dinaburg49c1dc8d163decae1f471d8d";}url|s:3:"lp0";razdel|i:0;language|s:3:"rus";ovner|s:14:"VHALS-DINABURG";head|s:130:"";nomerlast|i:250;nomerprev|i:251;gdd|s:2:"21";gdm|s:1:"9";gdy|s:4:"2003";gazeta_date|s:25:"воскресение, 21 сентябрья";nomerlastdate|s:10:"09/21/2003";
3) now i try to unserialize this output
$ff = unserialize($ff);
var_dump($ff);
then if i type print_r($ff);
i see bool(false)
what this means ????
thanks for helping
This might get you started. Run this on a single page, and you'll understand what it shows you. However, I'm not sure it's good practice to do it like this in reallife.
Code: Select all
<?php
echo '<pre>';
$string = 'foo|s:3:"bar";bar|s:3:"foo";foofoo|s:6:"barbar";barbar|s:6:"foofoo";';
$string = substr($string,0,-1); // strip the last ;
$string = explode(';',$string); // explode the main ones
print_r($string); // debug
foreach($string as $value) {
$newstring = explode('|',$value);
echo '<hr />';
foreach ($newstring as $parts) {
$x = explode(':',$parts);
print_r($x);
}
}
?>As I wrote in my first post, FALSE means the input is not valid, your data was not stored or received right.
I see no reason to manually analyze the string the way Jam is suggesting (what is that for? a serialized string is descriptors/attributes/content, not a bunch of values).
Where is the beginning "mdat|" in your string coming from Marco? I don't think that is supposed to be there, or there are missing stuff... Take a look at your storage procedure
A complete serialized array could look like this:
a:2:{i:0;s:5:"hello";i:1;s:3:"hey";}
I see no reason to manually analyze the string the way Jam is suggesting (what is that for? a serialized string is descriptors/attributes/content, not a bunch of values).
Where is the beginning "mdat|" in your string coming from Marco? I don't think that is supposed to be there, or there are missing stuff... Take a look at your storage procedure
A complete serialized array could look like this:
a:2:{i:0;s:5:"hello";i:1;s:3:"hey";}
Are you asking me?Stoker wrote:what is that for?
...
His string translated (looks wierd tho):
Code: Select all
Array
(
їmdat] => Array
(
їfusername] => darconi8
їfmemberof] => 2
їfbannews] => 0
їfauth] => 1
їmsession] => dinaburg49c1dc8d163decae1f471d8d
)
їurl] => lp0
їrazdel] => 0
їlanguage] => rus
їovner] => VHALS-DINABURG
їhead] => ";nomerlast|i:250;nomerprev|i:251;gdd|s:2:"21";gdm|s:1:"9";gdy|s:4:"2003";gazeta_date|s:25:"воскр
ї7;сение, 21 сентябрья";nomerlastdate] => 09/21/2003
)