In my project i wanna use the last_insert_id() to be stored in a session variable and after that i wanna use that session variable i.e., the value of last_insert_id() in another page. How can i carry the last_insert_id() to some other page using session or storing it in a session variable ? Urgent pls... :) Thanks

session_start();
// INSERT query here
$_SESSION['last_insert'] = mysql_insert_id($link);

That should give you the gist of it.

Member Avatar for diafol

depends what you want to do with this - if just to propogate - fine. But if you want to use it as an absolute last id in the DB table - perhaps not so good if you have multiple users with insert/delete access to said table.

I'm not even going to comment at this point ...... Ardav has it nuts on. I've learned as much from Ardav as you are about to plus some .... I'll leave it at that. Listen to what he has to say.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.