PHP

Moderators: None (Apply to moderate this forum)
Number of threads: 1848
Number of posts: 5016

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
How to handle user session along with jquery and php Posted by ityler on 16 Apr 2012 at 6:56 PM
I have a website that requires the user to choose 1 of 2 locations and then redirects to the website content running the appropriate jquery functions associated with each location choice. How can I handle a "session" with PHP once the user makes the location selection how can I carry that choice into the other pages of the website.
I already have a cookie being set and read with javascript but I would like the site to function properly even with out cookies.

Im not very experienced with PHP or sessions at all but to me it seems as though I need php to create and store a session variable once the location is selected but I am unsure of how to check the session info with jquery/javascript. Or even the proper way to create and end the session with PHP in this case. Thanks for the help!!
Report
Re: How to handle user session along with jquery and php Posted by hyphentech on 27 Jun 2012 at 2:47 AM
Hi,

With the help of cookies you can handle these session along with jquery and php.


Website Design Company | Graphics Design Services
Report
Re: How to handle user session along with jquery and php Posted by wartes on 29 Jun 2012 at 3:59 AM
Hello,
et a header in
<head><,/head> -connection session-

try to register the condition -
if isset($session1) == set the desired 
value.
Report
Re: How to handle user session along with jquery and php Posted by wartes on 29 Jun 2012 at 3:50 AM
Hello,
et a header in <head><,/head> -connection session-
try to register the condition - if isset($session1) == set the desired value.
Report
Re: How to handle user session along with jquery and php Posted by BudnetCBE on 2 Jul 2012 at 11:14 PM
You can't do it through jQuery alone; you'll need a combination of Ajax (which you can do with jQuery) and a PHP back-end. A very simple version might look like this:

HTML:

<img class="foo" src="img.jpg" />
<img class="foo" src="img2.jpg" />
<img class="foo" src="img3.jpg" />

Javascript:

$("img.foo").onclick(function()
{
// Get the src of the image
var src = $(this).attr("src");

// Send Ajax request to backend.php, with src set as "img" in the POST data
$.post("/backend.php", {"img": src});
});

PHP (backend.php):

<?php
// do any authentication first, then add POST variable to session
$_SESSION['imgsrc'] = $_POST['img'];
?>

How to web design contact us
SEO COIMBATORE|WEB DESIGN COMPANY
Report
Re: How to handle user session along with jquery and php Posted by wartes on 3 Jul 2012 at 10:13 AM
so the code will not work correctly -
I do not advise to use the


__________________________
watch free movie online



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.