close ad
WARNING: Do Not Install the DREAMWEAVER CC 2017 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

How to redirect users to previous page using SESSION and/or COOKIES

Thread began 4/27/2012 6:17 pm by danny405167 | Last modified 4/30/2012 9:42 am by danny405167 | 2465 views | 1 replies

danny405167

How to redirect users to previous page using SESSION and/or COOKIES

Is there a solution recipe for the following:
User logins from main page -> user is redirected to user profile page
if user logins from shop.php page -> users is redirected to previous page

Below is a pieceof code that I found on this forum and works perfect for redirecting users based on their user level. Now I would like to make it redirect to previous page when users do not log in from main page.

<?php
if(!session_id()) session_start();
switch($_SESSION['userLevel']) {
case "1":
header("Location: admin_index.php");
break;
case "2":
header("Location: clients_index.php");
break;
}
?>


The problem that I have is
1) Can the above code have an else if statement to add the third scenario? If so, can you please tell what is wrong with the code below.

<?php
if(!session_id()) session_start();
switch($_SESSION['userLevel']) {
case "1":
header("Location: admin_index.php");
break;
case "2":
header("Location: clients_index.php");
break;
}
else if(!session_id()) session_start();
switch($_SESSION['userLevel']=9) {
case "3":
header("Location: admin_index.php");
}
?>

2) How do I add a SESSION to shop.php page so that Security Assist knows to redirect the user to the previous page and not the control page. I found and added the following code to the shop.php page but no luck. Does Security Assist has a function to add the SESSION to the page or I will have to hand code it allays?

<?php
if (!session_id()) session_start();
if(!isset($_SESSION["userLevel"])) {
$_SESSION["userLevel"] = "9";
}
?>

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...