Jump to content

Is there a trick to redirection?


Go to solution Solved by opentype,

Recommended Posts

I am on the hosted platform, but no access to email support yet.  I am using only the following code in a custom php block.

header("Location: https://myazurebox/id=". $_COOKIE["ips4_member_id"]);

When I call this block, nothing happens.    I can see the cookies are there.

If I add the exit command:

header("Location: https://myazurebox?id=". $_COOKIE["ips4_member_id"]);
exit();

I receive a generic error when I try to save the block.

Sorry!  The page you requested does not exist
Error code: 1S160/2

Edited by MartinLawrence
removed private info
Link to comment
Share on other sites

Blocks are parsed in the body. In order for the header() function to execute, it must be done before any output is sent. 

So I don’t think you can actually do redirects within blocks… instead, I believe you might want to do this within your term with template logic. 

Someone else can keep me honest on this however as I’m not a coder.  I just do system administration.  🙂 

Link to comment
Share on other sites

3 hours ago, opentype said:

A template redirect looks like this:

{{\IPS\Output::i()->redirect('https://server.com/something.htm');}}

 

Thank you.  I made a new page with just this on it and it worked great.  Thanks!

How would I go about appending a cookie to that? 

. $_COOKIE["ips4_member_id"]');}}

Comes out as this after redirection.

="%20.%20$_COOKIE["ips4_member_id"]

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

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