• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

How can I get user id from session in javascript?

javascriptphpcodeigniter


PHP Snippet 1:

<input id="userId" value="<?php $_SESSION['user_id'] ?>" style="display:none">

PHP Snippet 2:

$( document ).ready(function() {
   alert( $('#userId').val() );
   console.log('done');
});

Related Snippets

Laravel relationship belongsToMany with composite primary keys

How should I get started using PHPUnit as a testing framework for a bunch of functions and classes I have already made?

Sync Records With Default Values in Pivot Tables, Call to undefined method syncWithPivotDefaults()

How to install ZeroMQ for PHP on an Alpine Linux container?

Check If array is null or not in php

Magento 2 - Controller returning blank page

Sort multidimensional array by column value within a column

PHP - installing Xdebug on Mac with XAMPP (Unix File)

Is there a way to use the same parameter into multiple place in the same query with Eloquent? [duplicate]

Split array into 4-element chunks then implode into strings

yii2 and mssql insert varbinary into model

Laravel You requested 1 items, but there are only 0 items available

How to convert a carbon into string, to take the date only?

Limit login attempts in Laravel 5.7

how to retrieve the first and last instance of a row in pdo dataset

About Contact Privacy policy Terms and conditions