logo
down
shadow

Page Redirect when session end in ASP.Net MVC


Page Redirect when session end in ASP.Net MVC

By : Dutchy
Date : November 20 2020, 07:00 PM
To fix this issue Check the following setting under in your web.config file:
code :


Share : facebook icon twitter icon
How can i completly destroy session. if session not availbale redirect to login page

How can i completly destroy session. if session not availbale redirect to login page


By : Matt Molo
Date : March 29 2020, 07:55 AM
help you fix your problem Hello i am trying to destory session when i press signout button then it's logging out and redirecting to login page; but when click back in browser that page is loading with loign menu on top.
code :
<?php
session_start();
if($_SESSION['id']){
unset($_SESSION['id']); // destroys the specified session.

}

header('Location:index.php'); //redirect to preferred page after unset the session

?>
Codeigniter Session is not storing values when i redirect from login page to dashboard page

Codeigniter Session is not storing values when i redirect from login page to dashboard page


By : Stefano Trivellato
Date : March 29 2020, 07:55 AM
wish of those help Mysteriously your code works... with some changes. You still need to add in validation and other things, but this is more an exercise in debugging.
I did alter some things - Read through the code - to prevent some of your possible "next questions."
code :
class Login extends CI_Controller {

    public function __construct() {
        parent::__construct();
        $this->load->library('session');
        $this->load->helper('url');

        $this->load->model('login_m');
    }

    public function index() {
        $this->load->view('login_v');
    }

    public function Login_user() {
        // Debug - View Posted Data
        var_dump($_POST);

        // @todo Requires Validation
        $uname = $_POST['username'];
        $pwd = $_POST['password'];
        $data = $this->login_m->get_user($uname, $pwd);

        // Debug - Data from Model
        var_dump($data);

        if ($data != NULL) {
            $id = $data[0]->sid;
            $sdata = array('sid' => $id);
            $this->session->set_userdata($sdata);

            // Debug - View The Session data
            var_dump($this->session->userdata);
            // exit required to view the var_dump outputs
            // in this method so prevent the redirect
            // Comment it out to allow the redirect
            //exit();

            redirect("admission/dashboard");
            exit();
        } else {
            // Debug - View The Session data
            var_dump($this->session->userdata);

            $error_message = "Invalid Login Details";
            $this->session->set_flashdata('error_message',$error_message);
            redirect('login',$data);
        }

    }
}
class Login_m extends CI_Model {

    public function __construct() {
        parent::__construct();
    }

    /**
     * Simulate a good and bad login.
     */
    public function get_user($uname, $pwd) {

        // use for successful login testing
        $return_array[]= (object)array('sid'=>1);

        // use for failed login testing
        $return_array = NULL;

        return $return_array;
    }
}
<h2>This is the Login View</h2>
<?php
// $error_message isn't always passed in so we need to cater for that
$error_message = $this->session->flashdata('error_message');

if ( ! empty($error_message)): ?>
    <div>
        <p> <?= $error_message; ?></p>
    </div>
<?php endif; ?>

<form action="login/login_user" method="POST">
    <label>username</label>
    <input type="text" name="username" value="">
    <br>
    <label>password</label>
    <input type="password" name="password" value="">
    <br>
    <input type="submit" name="check_login" value="Login">
</form>
Create a page to redirect to a different page for my session based on usertype but only the second header location is re

Create a page to redirect to a different page for my session based on usertype but only the second header location is re


By : freilla13
Date : March 29 2020, 07:55 AM
With these it helps Create a page to redirect to a different page for my session based on user type but only the second header location is redirecting.
code :
if ($user_type == "1") {
Is there any easy way to redirect to session expire page after session timeout without redirecting to formauthentication

Is there any easy way to redirect to session expire page after session timeout without redirecting to formauthentication


By : GwethanaWyeth
Date : March 29 2020, 07:55 AM
I wish this help you After creating the SessionExpired.aspx page you need to add just a single line in head section in aspx (not .cs) of your pages. (I hope you have implemented master pages, so it will be added only at the master page)
After login redirect to different page with session and after log out destroy the session

After login redirect to different page with session and after log out destroy the session


By : N. Siotto
Date : March 29 2020, 07:55 AM
To fix this issue To destroy the session you can easily use session_destroy() function. Then you have to do is make every other pages restricted for others (Only accessible logged users). to do that you can use these kind of php code to the top of each page.
code :
<?php
session_start();
//This will check that user is logged in or not
if(!isset($_SESSION['user'])
{
   //this will redirect user to log in page if he is not logged user
   header("location:./login.php"); 
}
?>
Related Posts Related Posts :
  • Is there a new controller instance for each request?
  • How to create dynamic menu in asp.net mvc?
  • ASP.NET MVC Programming
  • ASP.NET MVC - creating and handling with URLs with Greater Than and Less Than characters
  • ASP.NET MVC: calling a controller method from view
  • Strategy in exporting to Excel with formatting from ASP.NET?
  • building an ASP NET MVC site, should i go with linq to sql?
  • ASP.NET MVC not serving default document
  • Passing parameters to telerik asp.net mvc grid
  • ASP.NET MVC pass information from controller to view WITHOUT ViewData, ViewModel, or Session
  • ASP.NET MVC application architecture "guidelines"
  • ASP.NET MVC 2 validation using DTOs instead of domain entities
  • Is there simple way how to join two RouteValueDictionary values to pass parameters to Html.ActionLink
  • How does Select statement works in a Dynamic Linq Query?
  • Spark view engine - why there is no VS integration in version 1.1?
  • How to fix a NHibernate lazy loading error "no session or session was closed"?
  • ModelBindingContext ModelName
  • ASP.NET MVC TempData used for wrong request
  • MVC actionlink posting List of complex type
  • Displaying an asterix when using Html.LabelFor() with a Required property
  • Could model unit tests be truly independent and how [ASP.NET MVC]
  • How to create dynamic view page in mvc2.0?
  • Can't place a breakpoint in asp.net master page file
  • Saving state between actions
  • Custom Authorization/Authentication with Repository pattern
  • How to execute SQL query in a new database?
  • Themeing and Master Pages
  • Hosting WCF Services in ASP.NET MVC Web Application
  • How do you link to an action that takes an array as a parameter (RedirectToAction and/or ActionLink)?
  • What logic can go in the view? (MVC)
  • Asp.net mvc class reference in session
  • Unit testing a controller in ASP.NET MVC 2 with RedirectToAction
  • How to edit the user details stored in aspnetdb without asp.net web administration tool?
  • ASP .net MVC Jqgrid data binding
  • using two submit buttons inside single form
  • How can I use routing in ReactJs?
  • Error checking in controller in ASP.NET Core MVC
  • MVC Mutilple Tables SQL question. What is the best practice
  • How to use Asp.net MVC Core with Asp.net Identity Core and WebAPi Core?
  • EF Core - Repository, Model or View Model
  • MVC Web API Angular App ('http://localhost:4200' has been blocked by CORS policy)
  • Convert Datetime from mvc to Oracle in multiple Date/time format?
  • Is it good way to update data in ASP.NET MVC?
  • Kentico 12 PageBuilder missing reference
  • Mutiple shared layout mvc
  • Preventing from manipulation of disabled fields using developer tool
  • ASP.NET Core MVC consuming Internal Web API without using Http request
  • In MVC how can I return a IQueryable result and display it in a view using actions
  • Dependency Injection with Unity MVC5 - InjectionFactory Deprecated
  • blazor.server.js file not found
  • Am new to Asp.Net and i just completed my first Application. How can i deploy to IIS server
  • Sum of hours (HH:MM) in Linq
  • How to registr Automapper configuration class in global.asax?
  • Cannot find System.Web.Mvc.UrlHelper.GenerateUrl in .Net Core 3.0
  • Managing user session in Micro frontend
  • How to Call Api Controller from another Api Controller In Same Project
  • App service takes too long to show up after publishing
  • How to get selected value of DropDownList in Post method MVC
  • Cannot implicitly convert type 'System.Collections.Generic.List<string>' to 'System.Collections.Generic.List<Mo
  • Iframe occasionally loses session cookies
  • shadow
    Privacy Policy - Terms - Contact Us © 35dp-dentalpractice.co.uk