Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sessiona redirect

Status
Not open for further replies.

MITPRO

IS-IT--Management
Jan 4, 2006
137
US
Hello people. I have a problem with my cart redirecting to the previous page i was looking at.

Example: You can try this yourself. My website is Anyway, i click a product or i click the shopping cart image for a product....if you're not logged in, it will prompt for logging in....Cool, but lets say i was looking at a products description, when i click the cart and log in, the page does not go back to the page i was looking at. Instead, it takes me to the registration page showing me my account info.

The code is as follows, if anyone can follow it:

Of course i have
<? ob_start();
session_start();

the code that does the work is:

$login_required=array("profile"=>1, "order_history"=>1);

if ($w=="basket")
include "./main.php";// include "./basket.php";
elseif (isset($login_required[$w])&&!@$_AUTH)
{
$w="login";
include "./main.php";
}
elseif ($w=="item_info")
{
include "blok/meta.php";
include "./main.php";
//include "blok/item.php";
}
else
include "./main.php";

//code added for deletion of old recent view data start
$q_recent="delete from recentview where vdate< NOW()";
$db->query($q_recent);
//code added for deletion of old recent view data end
?>

Now, im not sure if there is a way to redirect to the last page viewed, but if there is, can someone or anyone give me an axample of how this should work? Or can you explain how to get the user to now redirect to the cart since he/she has opted to place item in the cart?

Thanks.
 
There is $_SERVER['HTTP_REFERER'], but I wouldn't use it. Some browsers do not report HTTP referers.

I recommend that you set up in your code a variable that describes the "last action". Whenever the user's flow through your application has to be interrupted, your code should store where the user intended to go. When the interruption is handled, your code can then redirect the user to where he was intending to originally go.



Want the best answers? Ask the best questions! TANSTAAFL!
 
Thank you, but i need code example or reference to what you are explaining.
 
I'm not sure I can give you one. The only thing I know about how your site works is some script fragments. And please DO NOT treat my last sentence as an invitation to post 1000 lines of script code.

Your user has asked your site code to ad an item to his shopping cart, but your code is not going to do it because the user is not logged on. So your code is going to interrupt doing what your user wants to do so that the site can get the user to log in.

Once the user is logged in, what happens? Does the site go ahead and add the item to the cart? If so, what would your code have to store in order to be able to get back to the point of adding the appropriate item to his cart?



Want the best answers? Ask the best questions! TANSTAAFL!
 
I gotcha. I think thats a little more clear. That should give me enough to test some script. Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top