[SOLVED] Alternatives to Sessions?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Todd_Z
Forum Regular
Posts: 708
Joined: Thu Nov 25, 2004 9:53 pm
Location: U Michigan

[SOLVED] Alternatives to Sessions?

Post by Todd_Z »

I am passing a php file which generates bar charts 4 variables-
2 arrays, 2 strings.

I am doing this via $_SESSION vars, however this causing all the links to turn have PHPSESSID vars. Is there some way to pass these variables to the files without the use of sessions?
Last edited by Todd_Z on Fri Jun 03, 2005 8:21 am, edited 1 time in total.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

set your php.ini to this

Code: Select all

session.use_trans_sid = 0
to avoid the session id being shown in the url.

Alternatively, you can create your own class to handle session vars through a db.
User avatar
Todd_Z
Forum Regular
Posts: 708
Joined: Thu Nov 25, 2004 9:53 pm
Location: U Michigan

Post by Todd_Z »

Code: Select all

<?
 ini_set("session.use_trans_sid",0);
 session_start();
?>
Very first lines of the index, still have the phpsessids, any ideas?
Roja
Tutorials Group
Posts: 2692
Joined: Sun Jan 04, 2004 10:30 pm

Post by Roja »

Code: Select all

ini_set('url_rewriter.tags', ''); // Ensure that the session id is *not* passed on the url.
Syranide
Forum Contributor
Posts: 281
Joined: Fri May 20, 2005 3:16 pm
Location: Sweden

Post by Syranide »

Uhm actually, they SHOULD have PHPSESSID vars unless you specifically don't want it (links to another site) ... PHPSESSID is automatically appended (when echoing) to ensure the session is not lost. (as the browser didn't report any sessioncompability)
Roja
Tutorials Group
Posts: 2692
Joined: Sun Jan 04, 2004 10:30 pm

Post by Roja »

Syranide wrote:Uhm actually, they SHOULD have PHPSESSID vars unless you specifically don't want it (links to another site) ... PHPSESSID is automatically appended (when echoing) to ensure the session is not lost. (as the browser didn't report any sessioncompability)
The key is that last line. Unfortunately, php can be overzealous, and even with browsers that do allow cookies to be set, can rewrite urls. (In other words, sometimes/often, php will rewrite the urls even if the browser did report session compatibility).

Not to mention, the original poster specifically asked how you can turn that particular behavior off, which is what we answered.

The session url rewriting function can be turned off, and not lose the ability to have sessions. It just means that all users *must* allow cookies.
User avatar
Todd_Z
Forum Regular
Posts: 708
Joined: Thu Nov 25, 2004 9:53 pm
Location: U Michigan

Post by Todd_Z »

Code: Select all

ini_set('url_rewriter.tags', '');
^^^^ did the trick. Thanks!
Post Reply