FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


php sessions





mathiaus
Right I'm using sessions and they need to be passed on throught the pages in the url. No w I like all my pages to be html valid so I can show the buttons and serch engines like me better. However at the moment this isnt happening as the sessid isnt going in how i want it. Anyway after reserching so I could ask to have something specific done, php.net said ....

Quote:
Note: The arg_separator.output php.ini directive allows to customize the argument seperator. For full XHTML conformance, specify & there.


being confused and unsure wether this would be any help to you I did some reserch and found that it means this line in the php.ini file thingy

Code:
arg_separator.output = "&"


If possible could it please be changed to

Code:
arg_separator.output = "&"


This would help my site be compliant with current web standards and promote itself better. Plus I would love Frihost even more (if its possible to do so)

Many thanks in advance
Matt Laughing
nikolic
Changing the php.ini for everyone is not the answer to your needs. This fundamental change would likely break everyone else's everything...

You can set a local directive, if needed. You can do this by using ini_set(), ini_get() functions.

But really, just what are you doing with sessions?

If you are putting things into the sessions array, note that this is passed automatically between calls by PHP.

For instance, session_start() will set a unique ID that the PHP runtime uses to differentiate between requests. All pages that use sessions must invoke this function.

You can add variables to the array simply by assigning them:

Code:
$newVariable = "Remember Me";

$_SESSION['nowRemembered'] = $newVariable;


If you need to remember the value between requests for an extended period of time (at least longer than the php.ini file says to save them), save the session id to a cookie or database, and at a later time retreive those values and continue with the session.

It is more likely that you are trying to pass normal values through a URL querystring, ultimately rewriting the natural session handling (and sometimes things don't need to be in a session - it's good but a little chubby for some uses).

Anyway, judging from the context clues you have likely built your URL with the parameter values ("?parameter1=value1&parameter2=value2")
and then simply url_encoded the entire thing. This will make the special characters like "&" into elements like "&".

Don't do that. Wink

Only url encode the variables and then build your url string:

Code:
$encodedValue1 = url_encode( value1 );
$encodedValue2 = url_encode( value2 );

// check php.net for $_SERVER[] constants...
$baseUrl = $_SERVER['PHP_SELF'];

// concatinate url values
$newUrlToGet = $baseUrl . "?" . $encodedValue1 . "&" . $encodedValue2;

// load that page by providing header
// note that no content may be sent before this is used
header( "Location: $newUrlToGet" );


I don't believe that this has anything to do with web standards.

XHTML compliance refers only to the output received by the browser. XHTML is ultimately an XML format with vestigal elements such as html, head,body, and so on. But, while doing this it enforces the strict rules of XML such as including a Document Type Declaration, and assuring that all elements in the tree are complete and closed, and it may be usefully extended with other XML technologies (such as XSLT).

Browsers react to it in such a way that is not different than common html, however there are fewer allowances for mistakes - parsing these kinds of files for display (regardless of display on screen, or screen and braille reader) is easier to build correct, small, and fast.

Regarding content, now that is a different story. Use elements such as "&" in your content, not in the url that points to the file.

A final note, you can pass and retrieve your parameters through the $_POST[] array.

This is ultimately the method that php sessions use if cookies are available at the receiving end.

This way, nothing other than the base url is in the url (browser bookmarks only lead to the base file of any request, but that is a "feature" in my opinion.) but you still can pass all the data you need between scripts.

That way, with only a base url to index, search engines will love you all the more.

If you need sample code, look to the php.net website, there are plenty of user-supplied samples to learn from.
mathiaus
Its a script I'm using and it just passes the session id throught the url. I'd rather not mess round with the code so I'll just leave it.

using ini_set() thanks. Works like a treat! Laughing


--closed--
Related topics
PHP: Sessions and Cookies
PHP Sessions
php sessions
problems for indexing php pages in google.
PHP sessions and security
How to make a log in log out system for a website??
php sessions for different accounts
php SESSIONS question
$_COOKIE and $_SESSION help needed!
friendster issue
Trying to start out!!!
is there session in perl
PHP Sessions Issue
PHP Session Timeout/Max Life Time
This topic is locked: you cannot edit posts or make replies.    Frihost Forum Index -> General -> Suggestions

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.