Disable autologout on certain pages

Created on 21 January 2025, 6 months ago

Problem/Motivation

I can't disable autologout on certain pages ('/exam-media/*'). I tried using a custom hook_autologout_prevent, but it is not working.

/**
 * Implements hook_autologout_prevent().
 */
function mymodule_autologout_prevent() {
  $current_path = \Drupal::service('path.current')->getPath();
  if (\Drupal::service('path.matcher')->matchPath($current_path, '/exam-media/*')) {
    return TRUE;
  }
}

Thank you in advance for your help and solution.

๐Ÿ’ฌ Support request
Status

Active

Version

1.0

Component

Miscellaneous

Created by

๐Ÿ‡ต๐Ÿ‡ฑPoland adpo

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @adpo
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia divyansh.gupta Jaipur

    Working on it.

  • ๐Ÿ‡ต๐Ÿ‡ฑPoland adpo

    Thank you for the info.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia divyansh.gupta Jaipur

    Hello @adpo,
    Sorry for the delayed response. I have tried multiple approaches to resolve this issue, but it seems that the condition to check for the path is only being evaluated once and not returning as expected, allowing further checks to continue. I also attempted different implementations using JavaScript, but none were successful.
    Thus unassigning it from myself.

  • ๐Ÿ‡ต๐Ÿ‡ฑPoland adpo

    Thank you, Divyansh for your support. I have tried several solutions also and I am surprised that it doesnโ€™t work

Production build 0.71.5 2024