Jump to content

Session from PHP through JS?


Hooch

Recommended Posts

Hey all.Is it possible to have a JS file carry my sessions?I have 1 important session that gets lost when I update something via JS.Thank you(I'm Googling for answers still)

Link to comment
Share on other sites

Now how would I add the session to a link?Here is the code in the .js file

window.location.href='page.php';

I would like to have something like

window.location.href='page.php?t2=<?php echo $_SESSION['xxx']; ?>';

This returns the link exactly as you see it. It's not echo'ing the session.Thank you for your time.

Link to comment
Share on other sites

$_SESSION['xxx']

will get a variable "xxx" that's part of the current PHP session... do you have such a variable?BTW, what you're trying to do is probably a bad idea... what exactly are you trying to do? There's perhaps a better way to deal with it altogether.

Link to comment
Share on other sites

Thanks boen.I will try to explain my problem.I have paid someone to create a project for me that involves draggingimages in a set admin area. I then save the current positions of all theimages and then use this to display on the front end. Now comes the hard part.The current set up works great for retrieving from 1 table in the database.I want to make this more dynamic. Plus to make this even more difficultI have the option to add and subtract categories of images.What I have so far:The php part is pretty much done. I can select from any category created.I have 4 javascript files that are used in the static version. I want to make2 of these dynamic, so all my categories will use the same (4) .js files.I have the dynamic selection of categories in 2 sessions (on the php pages).

$_SESSION['t2'] = $_GET['t2'];$_SESSION['t3'] = $_GET['t3'];

These same sessions will be used to update tables from the .js files and also used to link back to theoriginating php page.This is where

window.location.href='page.php?t2=<?php echo $_SESSION['xxx']; ?>';

Came from. So it actually should be

window.location.href='page.php?t2=<?php echo $_SESSION['t2']; ?>&t3=<?php echo $_SESSION['t3']; ?>';

I hope it's a little more clear.Thank you

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...