SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Feb 2004
    Location
    India
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question !! IMPORTANT !! HOW TO READ SESSION Data stored in the MySQL Tables

    Hi,
    I am storing the session variables in the MySQL Tables. The session values are stored in the format shopSessID|s:32:"d948b85ebb1b1bad95119c2aee072cc1";subID|s:5:"False";

    Please advise me how to read this format as in

    ShopSessID = d948b85ebb1b1bad95119c2aee072cc1
    subID = False

    Thanks

  2. #2
    eschew sesquipedalians silver trophy sweatje's Avatar
    Join Date
    Jun 2003
    Location
    Iowa, USA
    Posts
    3,749
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    see the php manual for serialize and unserialize
    Jason Sweat ZCE - jsweat_php@yahoo.com
    Book: PHP Patterns
    Good Stuff: SimpleTest PHPUnit FireFox ADOdb YUI
    Detestable (adjective): software that isn't testable.

  3. #3
    SitePoint Member
    Join Date
    Feb 2004
    Location
    India
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have just written the simple code using the unserialize function

    $variable='shopSessID|s:32:"f3ca21bf090e28b38ac5412d06a253ba";subID|s:5:"False";';
    $session_Date=unserialize($variable);

    --I am getting this error. Please tell me how to resolve this error and i am new to serialize and unserialize functions

    Error :
    Notice: unserialize() [function.unserialize]: Error at offset 0 of 68 bytes in ******* on line 3

    Thanks,

  4. #4
    No. Phil.Roberts's Avatar
    Join Date
    May 2001
    Location
    Nottingham, UK
    Posts
    1,142
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The serialised data comes after the "shopSessID|" and "subID|" bits.

  5. #5
    No. Phil.Roberts's Avatar
    Join Date
    May 2001
    Location
    Nottingham, UK
    Posts
    1,142
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <?php

    $string 
    'shopSessID|s:32:"d948b85ebb1b1bad95119c2aee072cc1";subID|s:5:"False";';

    $var_pairs explode(';'$string);

    foreach(
    $var_pairs as $var) {
        list(
    $k$v) = explode('|'$var);
        if(!empty(
    $k)) {
            
    $sess_array[$k] = unserialize($v);
        }
    }

    print_r($sess_array);

    ?>


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •