Jump to content

Search the Community

Showing results for tags '$session'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • Welcome to ProcessWire
    • News & Announcements
    • Showcase
    • Wishlist & Roadmap
  • Community Support
    • Getting Started
    • Tutorials
    • FAQs
    • General Support
    • API & Templates
    • Modules/Plugins
    • Themes and Profiles
    • Multi-Language Support
    • Security
    • Jobs
  • Off Topic
    • Pub
    • Dev Talk

Product Groups

  • Form Builder
  • ProFields
  • ProCache
  • ProMailer
  • Login Register Pro
  • ProDrafts
  • ListerPro
  • ProDevTools
  • Likes
  • Custom Development

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start





Website URL







Found 11 results

  1. I'm trying to identify if a user has logged in through our PW login. It's using $session->login. When including /pw/index.php and checking $user, it shows only a guest account after I have logged in. My project is in a higher directory than our PW instance. Is that why it's not showing a user being logged in? Thanks!
  2. Hello forum! I have a site, where I want to remember two settings defined by user: 1) Theme (light or dark) 2) Language (Finnish or English) Because user makes changes to these settings on client side, I am a bit lost with how can I save them in ProcessWire $session variable? I would like to use $session for more reliable saving, and since it is only two variables I will use, I doubt it will become too resource-needy. I have tried using jQuery's post() -method referring to a file in Templates folder (theme.php), but I get 403 Forbidden Error. I don't like the idea of trying to post to same file user currently is in, which is why I thought having a separate file would be good in this. Contents of theme.php: <?php namespace ProcessWire; header('Access-Control-Allow-Origin: https://domain.com'); $theme = $input->post['theme']; if(!empty($theme)) $session->theme = $theme; ?> Long story short: Does anybody have any pro tips I could use with setting and getting $session variables?
  3. Hi everybody I want to catch a variable from outside processwire into _main.php if(isset($_GET['u']) && $_GET['u'] !== ''){ $gebruikersnaam = $_GET['u']; ... ... This is working fine in a php file in a non processwire environment. In a processwire environment, I get the variable when I refer to /site/templates/_main.php but a great part of my template-code is not shown. From outside processwire I refer to mydomain/index.php. If I place $gebruikersnaam = $_GET['u']; in index.php, how can I pass through my variable to _main.php? Or is there an other solution? thx hansv
  4. Hello, I want to use the $session variable in functions, inside a template. According to the API this variable is available only in templates. But all values of the $session variable get lost, even when I use 'global $session'. is there any workaround for this problem?
  5. Hello everyone, i am building a little 'shop-like' element for a clients Homepage (no direct payment) Its my first Approach working with php besides very basic php and Processwire stuff, so i am a litte lost here. I want to use KnockoutJs for getting User Input, process the Data on the Server (pulling actual prices from a page) and send a single JSON Object, which holds all the Data needed for display in the UI back to knockout . The data will be send on every "keyup" in the front end. so i want the "checkout" array to be updated every time. I have some code already and it looks good so far. But obviously, with every ajax request ill get a new object with only the newest data back. <?php // Data comming on every "keyup" $hardMenge = $input->get->entities("hard"); $softMenge = $input->get->entities("soft"); // more to items will follow // Different products to choose from (actual prices will come from pages later) // More Products with different requierements will be added class Softcover { public $menge; public $preis; public function __construct($menge) { $this->menge = $menge; $this->preis = $menge * 10; } } class Hardcover { public $menge; public $preis; public $letter; public function __construct($menge, $letter) { $this->menge = $menge; $this->preis = $menge * 10; $this->letter = $letter; $this->total = $letter * .5 + $this->preis; } } $softy = new Softcover($softMenge); $harty = new Hardcover($hardMenge,2); $checkout = array(); $softOut = array("soft" => array("menge" => $softy->menge, "preis" => $softy->preis)); $hardOut = array("hart" => array("menge" => $harty->menge, "preis" => $harty->preis, "mitGravur" => $harty->total)); if (isset($softy) && ($softy->menge > 0)) { array_push($checkout, $softOut); } if (isset($harty) && ($harty->menge > 0)) { array_push($checkout, $hardOut); } // JSON object back to knockoutJS echo json_encode($checkout); My guess is i might use sessions eg $session here to keep all the data in the "checkout" array, and only refresh relevant parts of it on frontend "keyup"events. How could i use sessions to achieve that? Or is my Approach going nowere and i need to rethink everything? Thanks for helping out.
  6. I'm looking at the session information in the database. The "ts" column shows my local time formatted as text. The code in the wire/core/sessions.php file shows a check against the normal PHP/Unix "time()" function, which is GMT/UTC time. Shouldn't the timestamp in the DB be GMT/UTC? And pardon the next question; I'm still trying to grasp the structure of PW. How/where does Session.php fetch the 'ts' column from the database? I was trying to track down the answer to my own questions but couldn't find where the 'ts' column gets used. Context - I'm writing a lazy cron job to delete files if the session they are associated with has expired. It seems like the sessions in the DB need to be cleaned up as well - if I explicitly logout the session is deleted. But there are leftover sessions from months ago in the DB, so it looks like old sessions that just don't come back don't get deleted because the expiration logic doesn't delete the session record when it determines the session timed out.
  7. Hi guys. I have very strange problem that i cant managed fo few hours. This is realy hard to understand for me. I work on website and i want it to have banners in few places. In admin i created structure: Banners > Banner Group > Banner 1, Banner2, Banner 3 etc. I want this banners to be loaded one by one rather than randomly. I created function that print baner and save its id to session variable like this: function renderBannerBox($banner_group = false) { //takes banner group name as argument $out = ''; if ($banner_group) { $bgroup_url = '/banners/' . $banner_group . '/'; $bgroup = wire(pages)->get($bgroup_url); if ($bgroup->id) { $bgroup_id = $bgroup->id; //for every banner group create separate session variable to store displayed banners $session_name = $bgroup->name . '_array'; //get session variable with array of ids of displayed banners $displayed_banners = wire(session)->$session_name; $selector = "id!="; $selector .= substr($displayed_banners, 0, -1); $selector .= ", template=banner, parent=$bgroup_id"; $banners = wire(pages)->find("template=banner, parent=$bgroup_id"); $banner = $banners->get($selector); //if no banner (first view or all banners from group displayed) get random banner and if (! $banner->id) { $displayed_banners = ''; // clear $displayed banners variable $banner = $banners->findRandom(1)->first; //get random banner } //add current banner id to variable $displayed_banners .= $banner->id . '|'; // save variable to $session wire(session)->$session_name = $displayed_banners; // code for html formating } } Strange thing is that for every page refresh different number of banners ids are saved to my $session variable. One time is 1 id, second time 2 ids and so on. You can see it here: http://demo.webego.pl/ginfo/ - above every banner i print current value of $session variable. I tested it also in my main template file with independent test variable - it works the same way. It looks like page is sometimes 'double loaded'. Please let me know if you have any idea what is going on.
  8. Hi guys, I have a jquery mobile $session problem : Some background : The system itself is a mix between CodeIgniter and PW - customer login, business logic calculations are done via CI; however some static pages are displayed via PW. CI sets $_SESSIONS on login, which are then used from processwire; furthermore PW API is used by CI to create new pages, add text images, etc. All of the above works fine on a desktop/tablet The problem : That's where jQuery mobile comes. To detect mobile devices I've used this logic inside site/config.php: if( check_user_agent('mobile') ) { $config->urls->templates = '/site-mobile/templates/'; $config->paths->templates = $rootPath . $config->urls->templates; } It all works good - I get redirected accordingly; Sadly there is a but - On the mobile version after I (user) manually refresh the page or open another page the $session goes from this array(6) { ["Session"]=> array(0) { } ["username"]=> string(19) "my_email@gmail.com" ["firstname"]=> string(5) "Boris" ["lastname"]=> string(7) "Processwire" ["usertime"]=> int(1406733793) } to nothing: array(1) { ["Session"]=> array(0) { } } The original idea was for the mobile to sit on m.mysite.com ,but for cross domain requests, session and seo issues this is not an option. What have I tried with jQuery Mobile so far : disable ajax globally / page specifically force full urls e.g. from /page to www.mysite.com/page 'a' tags data-ajax=false pass sessions from $_SESSION to PW $session->varname - it goes empty on refresh As mentioned it all works fine on the desktop version, so I'm pretty sure that has something to do with jQuery mobile. Any ideas. suggestions, notes, topics or anything on the subject is highly appreciated! Please let me know if you want me to display more code samples.
  9. Hello, I've searched the forums and API page etc, but I've not really found a great deal of information regarding $session->hello = "Hello World!"; etc. I know what it does, but I don't know the technicalities of it. By this I mean, is it safe to temporarily store a couple of paragraphs of text in a session variable while a page is redirected for example? e.g $session->quotedText = "A couple of paragraphs of text would go here....."; $session->redirect($someUrl); // Get the stored text from the new page $value = $session->$quotedText; Echo "Quoted text from the previous page... " . $value; I can't see anything wrong with this idea, but I'm probably missing something as I can't seem to find many uses of it? Is this an improper use for session variables? Thanks.
  10. Hi, I have created a JS coundown timer displaying on a site. Example here: A-F33 At the moment the end date is hard coded into the function as a variable endDate. The time difference is based on the current time versus the endDate. What I would like to do is when a user arrives at the page the timer is set from that moment to a specific enddate, maybe based on a set number of days e.g 7, 14, 30 etc. Then when user 2 arrives at the page, say the next day the timer begins the countdown for that user for the same number of days. If user 1 returns to the page between the start of the coundown and the end he sees the time left relative to his visits and user 2 sees the time left relative to his visits, if that makes sense. I'm looking for advice on how to set this up and how to track each user. I thought I could use $session and set a custom expiry time. When the user's countdown reaches zero, I would like them to be taken to a custom page that explains that the offer has expired and what they can do next etc etc. So in a nutshell I would like each visitor to the page to have their own countdown initiated from their first visit. So each offer will have a set number of days to run for each user and at the end they are redirected to a n expiry page. I hope that makes sense?
  11. Hey, so now my first PW site is ready to go to the production server, but something's not working. I have set up a new database, dumped my local database and imported it. I then copied all files to the production server, changed the db settings in the config file, made site/assets writable and emptied site/cache. The .htaccess file is in the root folder. The site is running, but: I have a $session->redirect($page->children->first()->url); in the home template, which is not working (displays a 404 error). And, even worse, I can't login to the admin page. I assume that this is somehow connected to a session error... but I can't figure out where to look. I did a fresh install of PW on the same machine and all was good, so it must be an issue related to the transfer. Any hints are welcome... thanks.
  • Create New...