PDA

View Full Version : How do I pass the session ID in URL only when the user has cookies disabled ?


mihai11
08-31-2007, 12:55 PM
Hi,

I developed a custom page and I have a bit of a problem with users that have cookies disabled. When such users are visiting my custom page they get logged out automatically (because I am not passing the session ID variable to my custom page).

What is the best way to achieve this ? Should I look for the session ID in the URL – practically check the GET input for the session ID and if I find it then passed it along ?

This kind of stuff must be done everywhere in VB. I mean, each page normally should check from where the session ID is coming then alter the URLs on the page itself accordingly. I mean, let's suppose that the page contains some links for some places on the forum.

When cookies are enabled, the links will look like this:

<a href=”http://www.test.com/test1.php”> Test1 </a>
<a href=”http://www.test.com/test2.php”> Test2 </a>

OTOH, when cookies are disabled, the links will look like this:

<a href=”http://www.test.com/test1.php?s=dwef43r43drf43xsd4d43”> Test1 </a>
<a href=”http://www.test.com/test2.php?s=dwef43r43drf43xsd4d43”> Test2 </a>

How do I do the same in my own code ?

Regards,
Razvan

Princeton
08-31-2007, 02:12 PM
within templates, the session id is added via
$session[sessionurl] or $session[sessionurl_q]

within files
$vbulletin->session->vars['sessionurl'] OR $vbulletin->session->vars['sessionurl_q']

I suggest reviewing templates/files for examples

mihai11
08-31-2007, 02:19 PM
within templates, the session id is added via
$session[sessionurl] or $session[sessionurl_q]

within files
$vbulletin->session->vars['sessionurl'] OR $vbulletin->session->vars['sessionurl_q']

I suggest reviewing templates/files for examples

What is the difference between "sessionurl" and "sessionurl_q" ?

And most important: how do I know when to pass the variables in the URL ? There must be a way to know if the user has cookies enabled or disabled.

In some places I also found a third version:

$vbulletin->session->vars['sessionurl_js']

What is this version good for ?


Regards,
Razvan

Princeton
08-31-2007, 02:28 PM
vbulletin will know when to use it

['sessionurl'] with query such as .php?SESSIONdo=examples
['sessionurl_Q'] without query such as .phpSESSION

mihai11
08-31-2007, 02:37 PM
vbulletin will know when to use it

Basically, you are saying to append this string and VB will populate it when needed. Is that correct ?


['sessionurl'] with query such as .php?SESSIONdo=examples
['sessionurl_Q'] without query such as .phpSESSION


I am not sure what you mean here: use 'sessionurl' when more variables will follow in the URL and use 'sessionurl_Q' when the session itself is the only variable in the URL ?

Practically, the difference between the 2 is an "ampersand" and the end of the string. Is this correct ?

Princeton
08-31-2007, 02:42 PM
that is correct

the difference between the 2 is that ? gets added when no query is available
I suggest reviewing your templates and files for examples .. you can also test by disabling cookies in your browser.

mihai11
08-31-2007, 02:48 PM
that is correct

the difference between the 2 is that ? gets added when no query is available
I suggest reviewing your templates and files for examples .. you can also test by disabling cookies in your browser.

I already did what you suggested. The difference is as follows:

sessionurl = "s\=efeb241f3590c1f98a31deaa78501d5a&"
sessionurl_Q = "?s\=efeb241f3590c1f98a31deaa78501d5a"

So, the difference is in both an ampersand and and question mark (&?).

What about "sessionurl_js". When should I use that ?