Redirect & session variable problems

Helpdesk for my helpdesk software

Moderator: mkoch227

Post Reply
julian
Posts: 2
Joined: Mon Apr 16, 2012 11:51 am

Redirect & session variable problems

Post by julian »

Script URL: http://support.assimil8.com
Version of script: 2.3
Hosting company:
URL of phpinfo.php: http://support.assimil8.com/php_info.php
URL of session_test.php:
What terms did you try when SEARCHING for a solution: session, variable, redirect

Write your message below:

Hi
Brilliant software, will be using it as a helpdesk for some really important clients. I wanted to give it a more bespoke feel. I've changed the look somewhat, backgrounds, colours, logos etc. As a final part of this I've been trying to get the logo to change dynamically depending on which client we are looking at.

All pretty easy stuff with PHP. Using url tags and $_GET it's not a problem at all. Clearly that's a bit clunky, looks poor on the URL, needs to be implemented in many places and is open to abuse.

So I've been trying to set some &_SESSION variables. Much better. My idea was to set a redirect page for each client, set a session variable and then redirect. Then on the index page pick up the variable either in the header directly or in page itself. (for example http://support.assimil8.com/demo/redir.php and /index.php)

I've tried lots of different ways to get this working, to no avail.

For example,

Code: Select all

session_start();

$_SESSION['version'] = "demo";

/* Redirect browser using meta redirect*/
echo "<meta http-equiv='refresh' content='0;url=../index.php'>";

/* Make sure that code below does not get executed when we redirect. */
exit;
I've tried with and without starting the session, tried redeclaring the session variable on the page, etc etc.

It seems there is some conflict within the session processing for HESK. I don't want to start messing about with that (I tried to rename session_name['HESK'] to the value of a url tag, but that killed the whole lot (of course). And I'm not entirely sure how the session functions work anyway (bit too complex to work out easily).

Could anyone help?
Klemen
Site Admin
Posts: 10145
Joined: Fri Feb 11, 2005 4:04 pm

Re: Redirect & session variable problems

Post by Klemen »

The exact code is up to you as I don't provide support for such modifications, but as some general guidelines:

1. you can use HESK session, just make sure you use unique $_SESSION variable names. You can start it with (considering the redir file is in your HESK folder)

Code: Select all

define('IN_SCRIPT',1);
define('HESK_PATH','./');

/* Get all the required files and functions */
require(HESK_PATH . 'hesk_settings.inc.php');
require(HESK_PATH . 'inc/common.inc.php');

/* Start session */
hesk_session_start();
2. make sure the index page start sessions. By default it will only start it for 2 actions, you should delete existing

Code: Select all

hesk_session_start();
(twice) from index.php and paste

Code: Select all

hesk_session_start();
above line 43 ($action = ...)

3. You should make redirects by sending headers directly:

Code: Select all

header('Location: index.php');

Like said, the exact solution is up to you and if you can't get it to work you might need to hire someone for help as this is out of the scope of my support here.
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
julian
Posts: 2
Joined: Mon Apr 16, 2012 11:51 am

Re: Redirect & session variable problems

Post by julian »

Brilliant!

I tweaked my code (in the header.txt) slightly, moved the redirect page and that worked perfectly. It allows me to make the system appear client specific whilst maintaining one instance of it. Nice.

Thanks for your quick and excellent help. :D
Post Reply