Jump to content

Apache ErrorDocument and $_SESSION vars


Eric_S

Recommended Posts

Hi,

 

In my ErrorDocument I'd like to be able to set some variables for future use then redirect using header() and access them.

 

.htaccess has this entry in it: ErrorDocument 404 /error.php

 

I can pass variables in cookies and all works:

 

setcookie('my_var', 'my_val');

header ("Location: $url");

 

I would rather set $_SESSION variables but I can't get it to work.

 

session_start();

$_SESSION['my_var'] = 'my_val';

header ("Location: $url");

 

then...

 

echo $_SESSION['my_var']; returns "". This works fine from other php scripts but not from ErrorDocument. What am I doing wrong here?

 

.htaccess has this in it:

 

ErrorDocument 404 /error.php

 

TIA.

Link to comment
Share on other sites

Tried that too. I figured out the session_id changes but how can I grab the one from the last page or keep that session in the first place? I can pass the session_id in the query string but that's ugly. I can use cookies too and that works but sessions or post would be best.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.