Jump to content

Don't stick theme sessions


yggdrasil

Recommended Posts

Is there a way to make the session for a specific theme expire faster? Maybe with a cookie? Or passing something on the theme files?

Example, if someone loads a custom theme like six

whms.com?systpl=six

Should expire after 10 minutes. If the same users load then the page after 10 minutes, it will use again the default theme.

 

Link to comment
Share on other sites

Setting a _SESSION variable with time() and then checking if that is older (smaller) than the current time and if so, using session_unset(); and session_destroy(); to force the session "expired" should do the trick -- though have not tried.   Depending on where this is at, you could check $vars['template'] if it is the template you want to expire sooner otherwise you would need to use _GET probably.

Link to comment
Share on other sites

25 minutes ago, steven99 said:

Setting a _SESSION variable with time() and then checking if that is older (smaller) than the current time and if so, using session_unset(); and session_destroy(); to force the session "expired" should do the trick -- though have not tried.   Depending on where this is at, you could check $vars['template'] if it is the template you want to expire sooner otherwise you would need to use _GET probably.

I was trying to do this only for the theme (switch), not destroying the entire user sessions as that would log the user out of the account.

Link to comment
Share on other sites

Missed the last bit where you said you wanted the theme to switch back since you said and took expiring as expiring the session it self. 

21 hours ago, yggdrasil said:

Is there a way to make the session for a specific theme expire faster? Maybe with a cookie? Or passing something on the theme files?

 

I suppose you could use the same checking as mentioned above but instead of expiring the session, redirect via a php header(location: ?systpl=whatever) with additional checking that they did not go back to the theme. 

EDIT: there might be a variable in _SESSION also that handles which template.  print_r the _SESSION and see and then change it to see if that takes effect on next reload. 

Edited by steven99
Link to comment
Share on other sites

22 hours ago, steven99 said:

Missed the last bit where you said you wanted the theme to switch back since you said and took expiring as expiring the session it self. 

 

I suppose you could use the same checking as mentioned above but instead of expiring the session, redirect via a php header(location: ?systpl=whatever) with additional checking that they did not go back to the theme. 

EDIT: there might be a variable in _SESSION also that handles which template.  print_r the _SESSION and see and then change it to see if that takes effect on next reload. 

Yes, that was what I was looking, a specific session variable to just modify that specific theme but could not find one.

What I want is very simple and I assume others might also want this in the future.

I want to create a theme specific site that I will embed in a certain area. That theme should only be applied to that specific page. Switching the user and forcing him to a specific theme is the easy part, the problem is if they then go back to the normal pages. I don't want to pass the theme URL on every single page and link (this is not even possible now anymore as some internal links with WHMCS are hard coded and cannot be changed). This would also be a nightmare to maintain. So the obvious solution is to only switch users to the page specific theme and then make it quickly expire, in case they then go back to the normal site they will see the normal theme again. Example, set the theme to expire in 1 minute. That way I can force a theme on a specific URL, but it will only last for that page.

Not sure if there is a better idea to do this. You could then do things like have a mobile theme specific only, or maybe a theme only for a help section that has no headers and footers and only focus on the help article, and many other things but just creating different themes.

Since the theme is not set by cookie it seems, the only solution would be to directly tamper with the session, but since its encoded you cannot manipulate the theme setting only it seems. Otherwise, you could just change the session to switch the user theme.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated