[Webdev] Migrating Users using php and sessions

ad at m.beecher.net ad at m.beecher.net
Fri Sep 28 13:54:57 IST 2001


[I haven't looked at the code yet.]

Why not just generate the session key Anton? It's just a 32-character
alphanumeric string innit? The code for that is in the manual.

adam


> -----Original Message-----
> From: webdev-admin at linux.ie [mailto:webdev-admin at linux.ie]On Behalf Of
> AJ McKee
> Sent: 28 September 2001 18.04
> To: webdev at linux.ie
> Subject: [Webdev] Migrating Users using php and sessions
>
>
> Hi all,
>
> OK I have a wee problem guys,
>
> I am trying to migrate users from one database to another.
>
> The older one has no session field (PHPSESSIONID) whereas the
> newer one does.
>
> So I started out by doing a whiile loop to select all the users
> from the old
> table and then throwing them into an array. It would then start a
> session a
> phpsession and assign it using session_id to a var called
> $session. Then it
> would insert into the new table all the user data along with the
> new $session
> and then do a session_destroy()
>
> In theory it should have worked however all goes well except the session
> value in the database table is the same for evey user. Obvisould
> I don't want
> this.
>
> I could add a count but I was hoping there would be some way of
> doing this
> more simply.
>
> Anyone got any ideas? Sample of the code is below.
>
> <?
> // Call the config file
> require "../config/config.inc.php";
> // Do a lookup on the users table
> $query = mysql_query("SELECT * from users");
> // While loop with arrayed values
> while ($answer = mysql_fetch_array($query))
>       {
>        // For test purpose just get the userid
>        $userid = $answer["userid"];
>        // Start the session
>        session_start();
>         // Give the session a value
>        // Tried it with thsi and still same results
>        //session_register($userid);
>        // Get the session id
>        $session = session_id();
>         // Insert the new data into the new table
>        mysql_query("INSERT INTO test (session) VALUES ('$session')");
>        // Kill the session
>        session_destroy();
>        }
>       // Let me know when its done.
>       print("done");
> ?>
>
> Thanks in advance
> AJ
>
> _______________________________________________
> Webdev mailing list
> Webdev at linux.ie
> http://www.linux.ie/mailman/listinfo/webdev
>





More information about the Webdev mailing list