Jump to content

setting a session variable using a query string


uncleronin

Recommended Posts

This may sound a bit weird but is it possible to set a session variable using a query string? I can't find anything about this so I'm guessing its not possible? The reason is that I have a dynamic page which adjusts itself according to session variables. What I want to do is use different hyperlinks to trigger different content on the same page. So if i click a link called add it will go to page dyni and dyni will adapt to display the add stuff. I click a link called edit it will go to page dyni and dyni will adapt to display the edit stuff. I'm guessing its possible to manhandle the links and pages using javascript but I need to do it without js.

 

Is this even possible?

I think you may be getting a little confused because its sounds to me like you are asking for a template system. If your clicking links that trigger the event your also using $_GET not $_SESSION and this has nothing at all to do with queries.

 

Your initial question "setting a session variable using a query string" is possible but only in the sense that you would query data from a datasource and then assign a session variable with the field, value or array of values from that query.

 

You do not need Javascript to accomplish this, however if your looking to create a page which does not reload entirely, just certain aspects of it you would utilise AJAX which is to do with sending header information back to the server using Javascript (or other client script) without having to reload the whole page.

@Ted: Thats the kind of thing I was looking for! I haven't tested it yet but looks like it'll work.

 

@Cep: I guess I didn't use the right terminology there. What Ted showed is the kind of thing I was looking for. AJAX and any client-side scripting I cant use but with this string I can get the job done.

 

The thing is I am converting a site with about 1000 PHP pages (unpleasant!) so I'm trying to encapsulate multiple functionality within single pages. SO instead of having separate add, edit AND remove pages I only have 1 page - dyni.php (which is dynamic in the sense that it displays content according to its context - in this case either a session variable or a GET string is used). Atm I am doing this through an intermediate Management area (also on dyni.php) where you can select each option.

 

I'm sure there is likely to be a better way of doing this but I haven't PHP'ed much and am very new.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.